Showing
12 changed files
with
216 additions
and
128 deletions
@@ -3,6 +3,7 @@ package com.yohoufo.dal.order; | @@ -3,6 +3,7 @@ package com.yohoufo.dal.order; | ||
3 | import com.yohoufo.dal.order.model.EntrySellerRechargeOrder; | 3 | import com.yohoufo.dal.order.model.EntrySellerRechargeOrder; |
4 | import org.apache.ibatis.annotations.Param; | 4 | import org.apache.ibatis.annotations.Param; |
5 | 5 | ||
6 | +import java.math.BigDecimal; | ||
6 | import java.util.List; | 7 | import java.util.List; |
7 | 8 | ||
8 | public interface EntrySellerRechargeOrderMapper { | 9 | public interface EntrySellerRechargeOrderMapper { |
@@ -26,6 +27,8 @@ public interface EntrySellerRechargeOrderMapper { | @@ -26,6 +27,8 @@ public interface EntrySellerRechargeOrderMapper { | ||
26 | 27 | ||
27 | void updateByOrderCode(EntrySellerRechargeOrder order); | 28 | void updateByOrderCode(EntrySellerRechargeOrder order); |
28 | 29 | ||
30 | + int updateReturnDepositByOrderCode(@Param("orderCode") long orderCode, @Param("amount") BigDecimal amount, @Param("status") Integer status, @Param("updateTime") Integer updateTime); | ||
31 | + | ||
29 | EntrySellerRechargeOrder selectByOrderCodeUid(long orderCode, int uid); | 32 | EntrySellerRechargeOrder selectByOrderCodeUid(long orderCode, int uid); |
30 | 33 | ||
31 | EntrySellerRechargeOrder selectByOrderCode(long orderCode); | 34 | EntrySellerRechargeOrder selectByOrderCode(long orderCode); |
@@ -9,10 +9,10 @@ public interface IStoredSellerDao { | @@ -9,10 +9,10 @@ public interface IStoredSellerDao { | ||
9 | 9 | ||
10 | int insert(StoredSeller storedSeller); | 10 | int insert(StoredSeller storedSeller); |
11 | 11 | ||
12 | - int updateStatusByPrimaryKey(@Param("id")int id,@Param("validStatus") int validStatus ,@Param("expectStatus") int expectStatus); | 12 | + int updateStatusByUid(@Param("uid")int uid,@Param("validStatus") int validStatus ,@Param("expectStatus") int expectStatus,@Param("updateTime") long updateTime); |
13 | 13 | ||
14 | - int updateToQuitByPrimaryKey(@Param("id")int id,@Param("validStatus") int validStatus ,@Param("expectStatus") int expectStatus | 14 | + /*int updateToQuitByPrimaryKey(@Param("id")int id,@Param("validStatus") int validStatus ,@Param("expectStatus") int expectStatus |
15 | ,@Param("operatorUid") int operatorUid,@Param("operatorName") String operatorName | 15 | ,@Param("operatorUid") int operatorUid,@Param("operatorName") String operatorName |
16 | - ,@Param("quitTime") long quitTime,@Param("updateTime") long updateTime); | 16 | + ,@Param("quitTime") long quitTime,@Param("updateTime") long updateTime);*/ |
17 | 17 | ||
18 | } | 18 | } |
@@ -139,7 +139,7 @@ | @@ -139,7 +139,7 @@ | ||
139 | where id = #{id,jdbcType=INTEGER} | 139 | where id = #{id,jdbcType=INTEGER} |
140 | </update> | 140 | </update> |
141 | 141 | ||
142 | - <update id="updateByOrderCode" parameterType="com.yohoufo.dal.order.model.BuyerOrder"> | 142 | + <update id="updateByOrderCode" parameterType="com.yohoufo.dal.order.model.EntrySellerRechargeOrder"> |
143 | update entry_seller_recharge_order | 143 | update entry_seller_recharge_order |
144 | set | 144 | set |
145 | <if test="status != null"> | 145 | <if test="status != null"> |
@@ -152,6 +152,15 @@ | @@ -152,6 +152,15 @@ | ||
152 | where order_code = #{orderCode,jdbcType=BIGINT} | 152 | where order_code = #{orderCode,jdbcType=BIGINT} |
153 | </update> | 153 | </update> |
154 | 154 | ||
155 | + <update id="updateReturnDepositByOrderCode"> | ||
156 | + update entry_seller_recharge_order | ||
157 | + set | ||
158 | + status = #{status,jdbcType=INTEGER}, | ||
159 | + amount = #{amount,jdbcType=DECIMAL}, | ||
160 | + update_time = #{updateTime,jdbcType=INTEGER} | ||
161 | + where order_code = #{orderCode} | ||
162 | + </update> | ||
163 | + | ||
155 | <select id="selectByOrderCodeUid" resultMap="BaseResultMap"> | 164 | <select id="selectByOrderCodeUid" resultMap="BaseResultMap"> |
156 | select | 165 | select |
157 | <include refid="Base_Column_List" /> | 166 | <include refid="Base_Column_List" /> |
@@ -35,17 +35,17 @@ | @@ -35,17 +35,17 @@ | ||
35 | #{createTime},#{updateTime}) | 35 | #{createTime},#{updateTime}) |
36 | </insert> | 36 | </insert> |
37 | 37 | ||
38 | - <update id="updateStatusByPrimaryKey"> | 38 | + <update id="updateStatusByUid"> |
39 | update stored_seller | 39 | update stored_seller |
40 | - set valid_status = #{validStatus} | ||
41 | - where id = #{id} and valid_status = #{expectStatus} | 40 | + set valid_status = #{validStatus},update_time = #{updateTime} |
41 | + where uid = #{uid} and valid_status = #{expectStatus} | ||
42 | </update> | 42 | </update> |
43 | 43 | ||
44 | - <update id="updateToQuitByPrimaryKey"> | 44 | + <!-- <update id="updateToQuitByPrimaryKey"> |
45 | update stored_seller | 45 | update stored_seller |
46 | set valid_status = #{validStatus},operator_uid = #{operatorUid},operator_name=#{operatorName}, | 46 | set valid_status = #{validStatus},operator_uid = #{operatorUid},operator_name=#{operatorName}, |
47 | quit_time = #{quitTime} ,update_time = #{updateTime} | 47 | quit_time = #{quitTime} ,update_time = #{updateTime} |
48 | where id = #{id} and valid_status = #{expectStatus} | 48 | where id = #{id} and valid_status = #{expectStatus} |
49 | - </update> | 49 | + </update>--> |
50 | 50 | ||
51 | </mapper> | 51 | </mapper> |
@@ -36,29 +36,6 @@ public class SellerOrderController { | @@ -36,29 +36,6 @@ public class SellerOrderController { | ||
36 | private SellerOrderComputeHandler sellerOrderComputeHandler; | 36 | private SellerOrderComputeHandler sellerOrderComputeHandler; |
37 | 37 | ||
38 | 38 | ||
39 | - /** | ||
40 | - * 获取商家未完成的订单数量 | ||
41 | - * @param uid | ||
42 | - */ | ||
43 | - @RequestMapping(params = "method=ufo.sellerOrder.getUnfinishedOrderBySellerUid") | ||
44 | - @ResponseBody | ||
45 | - public ApiResponse getUnfinishedOrderBySellerUid(@RequestParam(name = "uid")Integer uid){ | ||
46 | - logger.info("in ufo.sellerOrder.getUnfinishedOrderBySellerUid, uid {}", uid); | ||
47 | - int total=sellerOrderService.getUnfinishedOrderBySellerUid(uid); | ||
48 | - return new ApiResponse.ApiResponseBuilder().code(200).data(total).build(); | ||
49 | - } | ||
50 | - | ||
51 | - /** | ||
52 | - * 获取商家出售中的商品数量 | ||
53 | - * @param uid | ||
54 | - */ | ||
55 | - @RequestMapping(params = "method=ufo.sellerOrder.getCanSellSkupBySellerUid") | ||
56 | - @ResponseBody | ||
57 | - public ApiResponse getCanSellSkupBySellerUid(@RequestParam(name = "uid")Integer uid){ | ||
58 | - logger.info("in ufo.sellerOrder.getUnfinishedOrderBySellerUid, uid {}", uid); | ||
59 | - int total=sellerOrderService.getCanSellSkupBySellerUid(uid); | ||
60 | - return new ApiResponse.ApiResponseBuilder().code(200).data(total).build(); | ||
61 | - } | ||
62 | 39 | ||
63 | /** | 40 | /** |
64 | * 根据卖家提交价格来计算各项费用 | 41 | * 根据卖家提交价格来计算各项费用 |
1 | package com.yohoufo.order.controller; | 1 | package com.yohoufo.order.controller; |
2 | 2 | ||
3 | import com.yohoufo.common.ApiResponse; | 3 | import com.yohoufo.common.ApiResponse; |
4 | +import com.yohoufo.common.exception.GatewayException; | ||
4 | import com.yohoufo.order.model.request.ShoppingRequest; | 5 | import com.yohoufo.order.model.request.ShoppingRequest; |
5 | import com.yohoufo.order.model.response.OrderSubmitResponse; | 6 | import com.yohoufo.order.model.response.OrderSubmitResponse; |
6 | import com.yohoufo.order.service.IStoredSellerDepositService; | 7 | import com.yohoufo.order.service.IStoredSellerDepositService; |
@@ -9,6 +10,7 @@ import org.slf4j.LoggerFactory; | @@ -9,6 +10,7 @@ import org.slf4j.LoggerFactory; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
10 | import org.springframework.stereotype.Controller; | 11 | import org.springframework.stereotype.Controller; |
11 | import org.springframework.web.bind.annotation.RequestMapping; | 12 | import org.springframework.web.bind.annotation.RequestMapping; |
13 | +import org.springframework.web.bind.annotation.RequestParam; | ||
12 | import org.springframework.web.bind.annotation.ResponseBody; | 14 | import org.springframework.web.bind.annotation.ResponseBody; |
13 | 15 | ||
14 | /** | 16 | /** |
@@ -48,4 +50,19 @@ public class StoredSellerDepositController { | @@ -48,4 +50,19 @@ public class StoredSellerDepositController { | ||
48 | return new ApiResponse.ApiResponseBuilder().data(null).code(200).message("保证金充值订单生成,请支付").build(); | 50 | return new ApiResponse.ApiResponseBuilder().data(null).code(200).message("保证金充值订单生成,请支付").build(); |
49 | } | 51 | } |
50 | 52 | ||
53 | + /** | ||
54 | + * 商户退驻 | ||
55 | + */ | ||
56 | + @RequestMapping(params = "method=ufo.sellerOrder.quitStoredSeller") | ||
57 | + public ApiResponse quitStoredSeller(@RequestParam("uid") Integer uid) throws GatewayException { | ||
58 | + logger.info("enter StoredSellerController quitStoredSeller param uid is {}", uid); | ||
59 | + //(1) 优先校验请求的参数 | ||
60 | + if (uid == null || uid <=0 ){ | ||
61 | + throw new GatewayException(400, "参数错误,uid不存在!"); | ||
62 | + } | ||
63 | + | ||
64 | + storedSellerDepositService.quitStoredSellerAndReturnDeposit(uid); | ||
65 | + return new ApiResponse(); | ||
66 | + } | ||
67 | + | ||
51 | } | 68 | } |
@@ -8,4 +8,6 @@ public interface IStoredSellerDepositService { | @@ -8,4 +8,6 @@ public interface IStoredSellerDepositService { | ||
8 | OrderSubmitResponse depositPreStore(ShoppingRequest shoppingRequest); | 8 | OrderSubmitResponse depositPreStore(ShoppingRequest shoppingRequest); |
9 | 9 | ||
10 | OrderSubmitResponse depositRecharge(ShoppingRequest shoppingRequest); | 10 | OrderSubmitResponse depositRecharge(ShoppingRequest shoppingRequest); |
11 | + | ||
12 | + void quitStoredSellerAndReturnDeposit(Integer uid); | ||
11 | } | 13 | } |
1 | package com.yohoufo.order.service; | 1 | package com.yohoufo.order.service; |
2 | 2 | ||
3 | -import java.math.BigDecimal; | ||
4 | -import java.util.Arrays; | ||
5 | -import java.util.Date; | ||
6 | -import java.util.List; | ||
7 | - | ||
8 | -import org.slf4j.Logger; | ||
9 | -import org.slf4j.LoggerFactory; | ||
10 | -import org.springframework.beans.factory.annotation.Autowired; | ||
11 | -import org.springframework.stereotype.Service; | ||
12 | - | ||
13 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
14 | import com.yoho.core.common.utils.DateUtil; | 4 | import com.yoho.core.common.utils.DateUtil; |
15 | import com.yoho.error.ServiceError; | 5 | import com.yoho.error.ServiceError; |
@@ -22,22 +12,23 @@ import com.yohobuy.ufo.model.order.common.TabType; | @@ -22,22 +12,23 @@ import com.yohobuy.ufo.model.order.common.TabType; | ||
22 | import com.yohoufo.common.alarm.CommonAlarmEventPublisher; | 12 | import com.yohoufo.common.alarm.CommonAlarmEventPublisher; |
23 | import com.yohoufo.common.caller.UfoServiceCaller; | 13 | import com.yohoufo.common.caller.UfoServiceCaller; |
24 | import com.yohoufo.common.utils.TimeUtils; | 14 | import com.yohoufo.common.utils.TimeUtils; |
25 | -import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper; | ||
26 | -import com.yohoufo.dal.order.OrdersPayMapper; | ||
27 | -import com.yohoufo.dal.order.OrdersPayRefundMapper; | ||
28 | -import com.yohoufo.dal.order.SellerWalletDetailMapper; | ||
29 | -import com.yohoufo.dal.order.SellerWalletMapper; | ||
30 | -import com.yohoufo.dal.order.model.EntrySellerRechargeOrder; | ||
31 | -import com.yohoufo.dal.order.model.OrdersPay; | ||
32 | -import com.yohoufo.dal.order.model.OrdersPayRefund; | ||
33 | -import com.yohoufo.dal.order.model.SellerWallet; | ||
34 | -import com.yohoufo.dal.order.model.SellerWalletDetail; | 15 | +import com.yohoufo.dal.order.*; |
16 | +import com.yohoufo.dal.order.model.*; | ||
35 | import com.yohoufo.order.common.Payment; | 17 | import com.yohoufo.order.common.Payment; |
36 | import com.yohoufo.order.model.request.PaymentRequest; | 18 | import com.yohoufo.order.model.request.PaymentRequest; |
37 | import com.yohoufo.order.model.response.PrepayResponse; | 19 | import com.yohoufo.order.model.response.PrepayResponse; |
38 | import com.yohoufo.order.service.cache.CacheCleaner; | 20 | import com.yohoufo.order.service.cache.CacheCleaner; |
39 | import com.yohoufo.order.service.cache.CacheKeyBuilder; | 21 | import com.yohoufo.order.service.cache.CacheKeyBuilder; |
40 | import com.yohoufo.order.service.impl.PaymentServiceImpl; | 22 | import com.yohoufo.order.service.impl.PaymentServiceImpl; |
23 | +import org.slf4j.Logger; | ||
24 | +import org.slf4j.LoggerFactory; | ||
25 | +import org.springframework.beans.factory.annotation.Autowired; | ||
26 | +import org.springframework.stereotype.Service; | ||
27 | + | ||
28 | +import java.math.BigDecimal; | ||
29 | +import java.util.Arrays; | ||
30 | +import java.util.Date; | ||
31 | +import java.util.List; | ||
41 | 32 | ||
42 | @Service | 33 | @Service |
43 | public class MerchantOrderPaymentService extends AbstractOrderPaymentService { | 34 | public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
@@ -341,8 +332,12 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { | @@ -341,8 +332,12 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { | ||
341 | } | 332 | } |
342 | 333 | ||
343 | // 商家退出入驻,钱包清空+转账 | 334 | // 商家退出入驻,钱包清空+转账 |
344 | - public boolean returnAllEarnest(Integer uid, long orderCode, String alipayAccount) { | ||
345 | - BigDecimal money = returnEarnest(uid, orderCode); | 335 | + public BigDecimal getReturnMoney(Integer uid, long orderCode){ |
336 | + BigDecimal money = returnEarnest(uid, orderCode); | ||
337 | + return money; | ||
338 | + } | ||
339 | + | ||
340 | + public boolean returnAllEarnest(Integer uid, long orderCode,BigDecimal money, String alipayAccount) { | ||
346 | if (money == null) { | 341 | if (money == null) { |
347 | return false; | 342 | return false; |
348 | } | 343 | } |
@@ -4,16 +4,21 @@ import com.alibaba.fastjson.JSON; | @@ -4,16 +4,21 @@ import com.alibaba.fastjson.JSON; | ||
4 | import com.yoho.error.ServiceError; | 4 | import com.yoho.error.ServiceError; |
5 | import com.yoho.error.exception.ServiceException; | 5 | import com.yoho.error.exception.ServiceException; |
6 | import com.yoho.tools.common.beans.ApiResponse; | 6 | import com.yoho.tools.common.beans.ApiResponse; |
7 | +import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum; | ||
7 | import com.yohobuy.ufo.model.order.common.EntrySellerDepositType; | 8 | import com.yohobuy.ufo.model.order.common.EntrySellerDepositType; |
8 | import com.yohobuy.ufo.model.order.common.OrderCodeType; | 9 | import com.yohobuy.ufo.model.order.common.OrderCodeType; |
9 | import com.yohobuy.ufo.model.order.constants.OrderConstant; | 10 | import com.yohobuy.ufo.model.order.constants.OrderConstant; |
11 | +import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO; | ||
10 | import com.yohoufo.common.caller.UfoServiceCaller; | 12 | import com.yohoufo.common.caller.UfoServiceCaller; |
11 | import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper; | 13 | import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper; |
12 | import com.yohoufo.dal.order.model.EntrySellerRechargeOrder; | 14 | import com.yohoufo.dal.order.model.EntrySellerRechargeOrder; |
15 | +import com.yohoufo.order.common.Payment; | ||
13 | import com.yohoufo.order.model.request.ShoppingRequest; | 16 | import com.yohoufo.order.model.request.ShoppingRequest; |
14 | import com.yohoufo.order.model.response.OrderSubmitResponse; | 17 | import com.yohoufo.order.model.response.OrderSubmitResponse; |
15 | import com.yohoufo.order.service.IStoredSellerDepositService; | 18 | import com.yohoufo.order.service.IStoredSellerDepositService; |
19 | +import com.yohoufo.order.service.MerchantOrderPaymentService; | ||
16 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | 20 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; |
21 | +import org.apache.commons.lang3.StringUtils; | ||
17 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
18 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
19 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -40,6 +45,12 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi | @@ -40,6 +45,12 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi | ||
40 | @Autowired | 45 | @Autowired |
41 | EntrySellerRechargeOrderMapper entrySellerRechargeOrderMapper; | 46 | EntrySellerRechargeOrderMapper entrySellerRechargeOrderMapper; |
42 | 47 | ||
48 | + @Autowired | ||
49 | + SellerOrderService sellerOrderService; | ||
50 | + | ||
51 | + @Autowired | ||
52 | + MerchantOrderPaymentService merchantOrderPaymentService; | ||
53 | + | ||
43 | /** | 54 | /** |
44 | * 充值保证金 | 55 | * 充值保证金 |
45 | */ | 56 | */ |
@@ -140,6 +151,114 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi | @@ -140,6 +151,114 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi | ||
140 | 151 | ||
141 | } | 152 | } |
142 | 153 | ||
154 | + /** | ||
155 | + * 退出入驻 | ||
156 | + * @param uid | ||
157 | + */ | ||
158 | + @Override | ||
159 | + public void quitStoredSellerAndReturnDeposit(Integer uid){ | ||
160 | + logger.info("StoredSellerServiceImpl quitStoredSeller enter uid is {} ",uid); | ||
161 | + | ||
162 | + if(!isEntrySeller(uid)){ | ||
163 | + logger.error("StoredSellerServiceImpl quitStoredSeller store seller isEntrySeller false,uid is {} ",uid); | ||
164 | + throw new ServiceException(400,"商户入驻状态为非入驻,不允许退驻!"); | ||
165 | + } | ||
166 | + | ||
167 | + Integer expectStatus= StoredSellerStatusEnum.entered.getId(); | ||
168 | + | ||
169 | + // 检查商户是否有出售中的商品,或者有订单未完成的 ,都不可以提交 | ||
170 | + Integer total=sellerOrderService.getUnfinishedOrderBySellerUid(uid); | ||
171 | + | ||
172 | + if(total!=null && total>0){ | ||
173 | + logger.error("quitStoredSeller not allowed cause of unfinished order ,uid {} ,total {}" ,uid,total); | ||
174 | + throw new ServiceException(400,"商户存在未完成订单,不允许退驻!"); | ||
175 | + } | ||
176 | + | ||
177 | + total=sellerOrderService.getCanSellSkupBySellerUid(uid); | ||
178 | + if(total!=null && total>0){ | ||
179 | + logger.error("quitStoredSeller not allowed cause of can seller product ,uid {} ,total {}" ,uid,total); | ||
180 | + throw new ServiceException(400,"商户存在出售中商品,不允许退驻!"); | ||
181 | + } | ||
182 | + | ||
183 | + String aliPayAccount = getAlipayAccount(uid); | ||
184 | + if(StringUtils.isBlank(aliPayAccount)){ | ||
185 | + logger.error("quitStoredSeller not allowed cause of aliPayAccount is blank ,uid {}" ,uid); | ||
186 | + throw new ServiceException(400,"商户存在出售中商品,不允许退驻!"); | ||
187 | + } | ||
188 | + | ||
189 | + | ||
190 | + ApiResponse<Integer> resp = ufoServiceCaller.call("ufo.user.updateStoredSellerQuitStatus", ApiResponse.class, uid); | ||
191 | + | ||
192 | + logger.info("StoredSellerServiceImpl quitStoredSeller call updateStoredSellerQuitStatus ,uid is {} ,resp is {} ",uid,resp); | ||
193 | + | ||
194 | + if(resp!=null&&resp.getCode()==200&&resp.getData()!=null&&(Integer)resp.getData()>0){ | ||
195 | + //创建一个退款订单 | ||
196 | + long orderCode = orderCodeGenerator.generate(OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE); | ||
197 | + BigDecimal amount=BigDecimal.ZERO; | ||
198 | + //保证金订单类型 | ||
199 | + Integer type = EntrySellerDepositType.GO_BACK.getType(); | ||
200 | + | ||
201 | + // 生成订单数据,insert db | ||
202 | + EntrySellerRechargeOrder entrySellerRechargeOrder=new EntrySellerRechargeOrder(); | ||
203 | + entrySellerRechargeOrder.setUid(uid); | ||
204 | + entrySellerRechargeOrder.setOrderCode(orderCode); | ||
205 | + entrySellerRechargeOrder.setPayment(Payment.ALIPAY.getCode()); | ||
206 | + entrySellerRechargeOrder.setStatus(0);//0 未支付,1已支付 | ||
207 | + entrySellerRechargeOrder.setAmount(amount); | ||
208 | + entrySellerRechargeOrder.setType(type); | ||
209 | + | ||
210 | + int now = (int) (System.currentTimeMillis()/1000); | ||
211 | + entrySellerRechargeOrder.setCreateTime(now); | ||
212 | + entrySellerRechargeOrder.setUpdateTime(now); | ||
213 | + | ||
214 | + logger.info("enter StoredSellerDepositServiceImpl quitStoredSellerAndReturnDeposit begin save entrySellerRechargeOrder {} ",entrySellerRechargeOrder); | ||
215 | + int num = entrySellerRechargeOrderMapper.insert(entrySellerRechargeOrder); | ||
216 | + logger.info("enter StoredSellerDepositServiceImpl quitStoredSellerAndReturnDeposit end save entrySellerRechargeOrder {} ,num {}",entrySellerRechargeOrder,num); | ||
217 | + | ||
218 | + //获取退款金额 | ||
219 | + BigDecimal returnAmount = merchantOrderPaymentService.getReturnMoney(uid,orderCode); | ||
220 | + // 执行退保证金的操作 | ||
221 | + logger.info("StoredSellerServiceImpl merchantOrderPaymentService begin ,uid {},returnAmount {} ",uid,returnAmount); | ||
222 | + | ||
223 | + boolean returnResult=false; | ||
224 | + if(returnAmount!=null){ | ||
225 | + returnResult=merchantOrderPaymentService.returnAllEarnest(uid,orderCode,returnAmount,aliPayAccount); | ||
226 | + logger.info("StoredSellerServiceImpl merchantOrderPaymentService end ,uid {}",uid); | ||
227 | + } | ||
228 | + | ||
229 | + //退保证金成功,更新记录 | ||
230 | + int orderStatus=0;//未支付 | ||
231 | + if(returnResult){ | ||
232 | + orderStatus=1;//已支付 | ||
233 | + } | ||
234 | + | ||
235 | + logger.info("StoredSellerServiceImpl updateReturnDepositByOrderCode ,orderCode {} ,returnAmount {} ,orderStatus {} ,ts {}", | ||
236 | + orderCode,returnAmount,orderStatus,now); | ||
237 | + int updateNum=entrySellerRechargeOrderMapper.updateReturnDepositByOrderCode(orderCode, | ||
238 | + returnAmount==null?BigDecimal.ZERO:returnAmount,orderStatus,now); | ||
239 | + logger.info("StoredSellerServiceImpl updateReturnDepositByOrderCode update num {} ,orderCode {} ,returnAmount {} ,orderStatus {} ,ts {}",updateNum, | ||
240 | + orderCode,returnAmount,orderStatus,now); | ||
241 | + | ||
242 | + }else{ | ||
243 | + logger.error("StoredSellerServiceImpl quitStoredSellerAndReturnDeposit update row is 0,uid {}",uid); | ||
244 | + throw new ServiceException(400,"商户退驻失败,请重新检查状态!"); | ||
245 | + } | ||
246 | + | ||
247 | + } | ||
248 | + | ||
249 | + | ||
250 | + @SuppressWarnings("unchecked") | ||
251 | + private String getAlipayAccount(int targetUid) { | ||
252 | + ApiResponse<AuthorizeResultRespVO> resp = ufoServiceCaller.call("ufo.user.aliPayAccountQuery", ApiResponse.class, targetUid); | ||
253 | + if (resp != null) { | ||
254 | + AuthorizeResultRespVO data = (AuthorizeResultRespVO) resp.getData(); | ||
255 | + if (data != null && data.getAlipayAccount() != null) { | ||
256 | + return data.getAlipayAccount(); | ||
257 | + } | ||
258 | + } | ||
259 | + return null; | ||
260 | + } | ||
261 | + | ||
143 | private BigDecimal getValidMoney(String money) { | 262 | private BigDecimal getValidMoney(String money) { |
144 | try { | 263 | try { |
145 | BigDecimal bd = new BigDecimal(money); | 264 | BigDecimal bd = new BigDecimal(money); |
@@ -2,7 +2,6 @@ package com.yohoufo.user.controller.passport; | @@ -2,7 +2,6 @@ package com.yohoufo.user.controller.passport; | ||
2 | 2 | ||
3 | import com.yoho.tools.common.beans.ApiResponse; | 3 | import com.yoho.tools.common.beans.ApiResponse; |
4 | import com.yohoufo.common.exception.GatewayException; | 4 | import com.yohoufo.common.exception.GatewayException; |
5 | -import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO; | ||
6 | import com.yohoufo.user.service.IStoredSellerService; | 5 | import com.yohoufo.user.service.IStoredSellerService; |
7 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
8 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
@@ -71,18 +70,18 @@ public class StoredSellerController { | @@ -71,18 +70,18 @@ public class StoredSellerController { | ||
71 | 70 | ||
72 | 71 | ||
73 | /** | 72 | /** |
74 | - * 商户退驻 | 73 | + * 更新商户状态为"退驻" |
75 | */ | 74 | */ |
76 | - @RequestMapping(params = "method=ufo.user.quitStoredSeller") | ||
77 | - public ApiResponse quitStoredSeller(RealNameAuthorizeReqVO reqVO) throws GatewayException { | ||
78 | - logger.info("enter StoredSellerController applyQuitStoredSeller param reqVO is {}", reqVO); | 75 | + @RequestMapping(params = "method=ufo.user.updateStoredSellerQuitStatus") |
76 | + public ApiResponse updateStoredSellerQuitStatus(@RequestParam("uid") Integer uid) throws GatewayException { | ||
77 | + logger.info("enter StoredSellerController updateStoredSellerQuitStatus param uid is {}", uid); | ||
79 | //(1) 优先校验请求的参数 | 78 | //(1) 优先校验请求的参数 |
80 | - if (reqVO == null || reqVO.getUid() <=0 ){ | 79 | + if (uid == null || uid <=0 ){ |
81 | throw new GatewayException(400, "参数错误,uid不存在!"); | 80 | throw new GatewayException(400, "参数错误,uid不存在!"); |
82 | } | 81 | } |
83 | 82 | ||
84 | - storedSellerService.quitStoredSeller(reqVO); | ||
85 | - return new ApiResponse(); | 83 | + Integer updateNum=storedSellerService.updateStoredSellerQuitStatus(uid); |
84 | + return new ApiResponse(updateNum); | ||
86 | } | 85 | } |
87 | 86 | ||
88 | } | 87 | } |
1 | package com.yohoufo.user.service; | 1 | package com.yohoufo.user.service; |
2 | 2 | ||
3 | -import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO; | ||
4 | - | ||
5 | public interface IStoredSellerService { | 3 | public interface IStoredSellerService { |
6 | 4 | ||
7 | boolean isStoredSeller(Integer uid); | 5 | boolean isStoredSeller(Integer uid); |
@@ -11,5 +9,5 @@ public interface IStoredSellerService { | @@ -11,5 +9,5 @@ public interface IStoredSellerService { | ||
11 | //void applyQuitStoredSeller(Integer uid); | 9 | //void applyQuitStoredSeller(Integer uid); |
12 | 10 | ||
13 | 11 | ||
14 | - void quitStoredSeller(RealNameAuthorizeReqVO reqVO); | 12 | + Integer updateStoredSellerQuitStatus(Integer uid); |
15 | } | 13 | } |
@@ -2,13 +2,11 @@ package com.yohoufo.user.service.impl; | @@ -2,13 +2,11 @@ package com.yohoufo.user.service.impl; | ||
2 | 2 | ||
3 | import com.yoho.error.exception.ServiceException; | 3 | import com.yoho.error.exception.ServiceException; |
4 | import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum; | 4 | import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum; |
5 | -import com.yohoufo.common.ApiResponse; | ||
6 | import com.yohoufo.common.caller.UfoServiceCaller; | 5 | import com.yohoufo.common.caller.UfoServiceCaller; |
7 | import com.yohoufo.dal.user.IStoredSellerDao; | 6 | import com.yohoufo.dal.user.IStoredSellerDao; |
8 | import com.yohoufo.dal.user.model.StoredSeller; | 7 | import com.yohoufo.dal.user.model.StoredSeller; |
9 | import com.yohoufo.dal.user.model.ZhiMaCert; | 8 | import com.yohoufo.dal.user.model.ZhiMaCert; |
10 | import com.yohoufo.user.cache.CacheService; | 9 | import com.yohoufo.user.cache.CacheService; |
11 | -import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO; | ||
12 | import com.yohoufo.user.service.IRealNameAuthorizeService; | 10 | import com.yohoufo.user.service.IRealNameAuthorizeService; |
13 | import com.yohoufo.user.service.IStoredSellerService; | 11 | import com.yohoufo.user.service.IStoredSellerService; |
14 | import org.slf4j.Logger; | 12 | import org.slf4j.Logger; |
@@ -37,67 +35,6 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | @@ -37,67 +35,6 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | ||
37 | private UfoServiceCaller ufoServiceCaller; | 35 | private UfoServiceCaller ufoServiceCaller; |
38 | 36 | ||
39 | 37 | ||
40 | - /** | ||
41 | - * 退出入驻 | ||
42 | - * @param reqVO | ||
43 | - */ | ||
44 | - @Override | ||
45 | - public void quitStoredSeller(RealNameAuthorizeReqVO reqVO){ | ||
46 | - logger.info("StoredSellerServiceImpl quitStoredSeller enter reqVO is {} ",reqVO); | ||
47 | - Integer uid=reqVO.getUid(); | ||
48 | - StoredSeller storedSeller = getValidStoredSeller(uid); | ||
49 | - if(null==storedSeller){ | ||
50 | - logger.error("StoredSellerServiceImpl quitStoredSeller store seller is null,uid is {} ",uid); | ||
51 | - throw new ServiceException(400,"未找到入驻信息"); | ||
52 | - } | ||
53 | - | ||
54 | - Integer expectStatus=StoredSellerStatusEnum.entered.getId(); | ||
55 | - if(!expectStatus.equals(storedSeller.getValidStatus())){ | ||
56 | - throw new ServiceException(400,"商户入驻状态变化,不允许退驻!"); | ||
57 | - } | ||
58 | - | ||
59 | - // 检查商户是否有出售中的商品,或者有订单未完成的 ,都不可以提交 | ||
60 | - ApiResponse apiResponse=ufoServiceCaller.call("ufo.sellerOrder.getUnfinishedOrderBySellerUid", ApiResponse.class,uid); | ||
61 | - if(apiResponse==null||apiResponse.getCode()!=200){ | ||
62 | - throw new ServiceException(400,"商户订单获取异常,不允许退驻!"); | ||
63 | - } | ||
64 | - Integer total =(Integer)apiResponse.getData(); | ||
65 | - if(total!=null && total>0){ | ||
66 | - logger.error("quitStoredSeller not allowed cause of unfinished order ,total {}" ,total); | ||
67 | - throw new ServiceException(400,"商户存在未完成订单,不允许退驻!"); | ||
68 | - } | ||
69 | - apiResponse=ufoServiceCaller.call("ufo.sellerOrder.getCanSellSkupBySellerUid", ApiResponse.class,uid); | ||
70 | - if(apiResponse==null||apiResponse.getCode()!=200){ | ||
71 | - throw new ServiceException(400,"商户商品获取异常,不允许退驻!"); | ||
72 | - } | ||
73 | - total =(Integer)apiResponse.getData(); | ||
74 | - if(total!=null && total>0){ | ||
75 | - logger.error("quitStoredSeller not allowed cause of can seller product ,total {}" ,total); | ||
76 | - throw new ServiceException(400,"商户存在出售中商品,不允许退驻!"); | ||
77 | - } | ||
78 | - | ||
79 | - | ||
80 | - LocalDateTime now=LocalDateTime.now(); | ||
81 | - long ts=now.toEpochSecond(ZoneOffset.of("+8")); | ||
82 | - | ||
83 | - //更新为退驻 | ||
84 | - int num = storedSellerDao.updateToQuitByPrimaryKey(storedSeller.getId(),StoredSellerStatusEnum.quit.getId(),expectStatus, | ||
85 | - reqVO.getOperatorUid(),reqVO.getOperatorName(), | ||
86 | - ts,ts); | ||
87 | - //清掉缓存 | ||
88 | - cacheService.removeStoredSeller(uid); | ||
89 | - | ||
90 | - logger.info("StoredSellerServiceImpl quitStoredSeller end ,uid is {} ,update num ",uid,num); | ||
91 | - | ||
92 | - if(num > 0){ | ||
93 | - //TODO 执行退保证金的操作 | ||
94 | - | ||
95 | - }else{ | ||
96 | - logger.error("StoredSellerServiceImpl quitStoredSeller update row is 0,reqVo {}",reqVO); | ||
97 | - } | ||
98 | - | ||
99 | - } | ||
100 | - | ||
101 | /*@Override | 38 | /*@Override |
102 | public void applyQuitStoredSeller(Integer uid){ | 39 | public void applyQuitStoredSeller(Integer uid){ |
103 | logger.info("StoredSellerServiceImpl applyQuitStoredSeller uid is {} ",uid); | 40 | logger.info("StoredSellerServiceImpl applyQuitStoredSeller uid is {} ",uid); |
@@ -190,4 +127,36 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | @@ -190,4 +127,36 @@ public class StoredSellerServiceImpl implements IStoredSellerService { | ||
190 | 127 | ||
191 | 128 | ||
192 | } | 129 | } |
130 | + | ||
131 | + @Override | ||
132 | + public Integer updateStoredSellerQuitStatus(Integer uid){ | ||
133 | + logger.info("StoredSellerServiceImpl updateStoredSellerQuitStatus uid is {} ",uid); | ||
134 | + StoredSeller storedSeller = getValidStoredSeller(uid); | ||
135 | + if(null==storedSeller){ | ||
136 | + logger.error("StoredSellerServiceImpl applyQuitStoredSeller store seller is null,uid is {} ",uid); | ||
137 | + throw new ServiceException(400,"未找到入驻信息"); | ||
138 | + } | ||
139 | + | ||
140 | + Integer expectStatus =StoredSellerStatusEnum.entered.getId(); | ||
141 | + if(!expectStatus.equals(storedSeller.getValidStatus())){ | ||
142 | + throw new ServiceException(400,"商户入驻状态变化,不允许退出!"); | ||
143 | + } | ||
144 | + | ||
145 | + //只能操作自己的uid | ||
146 | + if(!uid.equals(storedSeller.getUid())){ | ||
147 | + throw new ServiceException(400,"商户入驻操作错误,不允许退出!"); | ||
148 | + } | ||
149 | + | ||
150 | + LocalDateTime now=LocalDateTime.now(); | ||
151 | + long ts=now.toEpochSecond(ZoneOffset.of("+8")); | ||
152 | + | ||
153 | + //更新为退驻 | ||
154 | + logger.info("StoredSellerServiceImpl updateStoredSellerQuitStatus begin ,uid is {} ,ts {} ",uid,ts); | ||
155 | + int num = storedSellerDao.updateStatusByUid(uid,StoredSellerStatusEnum.quit.getId(),expectStatus,ts); | ||
156 | + //状态变化,清掉缓存 | ||
157 | + cacheService.removeStoredSeller(uid); | ||
158 | + | ||
159 | + logger.info("StoredSellerServiceImpl updateStoredSellerQuitStatus end ,uid is {} ,update num {}",uid,num); | ||
160 | + return num; | ||
161 | + } | ||
193 | } | 162 | } |
-
Please register or login to post a comment