|  |  | 
 |  |  | import com.xzx.gc.common.exception.RestException; | 
 |  |  | import com.xzx.gc.common.utils.IdUtils; | 
 |  |  | import com.xzx.gc.entity.*; | 
 |  |  | import com.xzx.gc.shop.dto.AddGoodsOrderDto; | 
 |  |  | import com.xzx.gc.shop.dto.DeliverGoodsDto; | 
 |  |  | import com.xzx.gc.shop.dto.InsureOrderDto; | 
 |  |  | import com.xzx.gc.shop.dto.QueryOrderListDto; | 
 |  |  | import com.xzx.gc.shop.dto.*; | 
 |  |  | import com.xzx.gc.shop.mapper.*; | 
 |  |  | import com.xzx.gc.shop.vo.ExpressInfoVo; | 
 |  |  | import com.xzx.gc.shop.vo.QueryOrderListVo; | 
 |  |  | 
 |  |  |  | 
 |  |  | import javax.annotation.Resource; | 
 |  |  | import java.math.BigDecimal; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  | import java.util.*; | 
 |  |  |  | 
 |  |  | @Service | 
 |  |  | @Transactional | 
 |  |  | 
 |  |  |             ObjectMapper objectMapper = new ObjectMapper(); | 
 |  |  |             objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | 
 |  |  |             viewOrderVo = objectMapper.convertValue(scoreOrder, ViewOrderVo.class); | 
 |  |  | //            String voucherImg = viewOrderVo.getVoucherImg(); | 
 |  |  |             String voucherImg = scoreOrder.getVoucherImg(); | 
 |  |  |             List<String> lists = StrUtil.splitTrim(voucherImg, ","); | 
 |  |  |             viewOrderVo.setVoucherImgs(lists); | 
 |  |  |             //2-待收货3-已收货4-已完成5-已评价,获取物流信息 | 
 |  |  |             Integer status = scoreOrder.getStatus() == null ? 0:scoreOrder.getStatus(); | 
 |  |  |             if(ScoreOrder.STATUS_DOING == status | 
 |  |  | 
 |  |  |     public Long insureOrder(InsureOrderDto model) { | 
 |  |  |         ScoreOrder scoreOrder = new ScoreOrder(); | 
 |  |  |         scoreOrder.setId(model.getId()); | 
 |  |  |         scoreOrder.setVoucherImg(model.getVoucherImgs().toString()); | 
 |  |  |         scoreOrder.setStatus(ScoreOrder.STATUS_DONE); | 
 |  |  |         scoreOrder.setVoucherImg(CollUtil.join(model.getVoucherImgs(),",")); | 
 |  |  |         scoreOrderMapper.updateByPrimaryKeySelective(scoreOrder); | 
 |  |  |         return scoreOrder.getId(); | 
 |  |  |     } | 
 |  |  | 
 |  |  |         if (goods == null || ScoreGoods.ISSALE_NO.equals(goods.getIsSale())) { | 
 |  |  |             throw new RestException(-3, "商品不存在或已下架"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (ScoreGoods.ISQG_YES.equals(goods.getIsQg())) { | 
 |  |  |             if (new Date().before(goods.getQgStartTime())) { | 
 |  |  |                 throw new RestException(-3, "抢购未开始"); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (new Date().after(goods.getQgEndTime())) { | 
 |  |  |                 throw new RestException(-3, "抢购已结束"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         AccountInfo accountInfo = accountInfoMapper.selectAccountInfoByUserId(addGoodsOrderDto.getUserId()); | 
 |  |  |  | 
 |  |  |         if (accountInfo.getCollectScore() == null) { | 
 |  |  | 
 |  |  |         expressInfo.setCreatedTime(new Date()); | 
 |  |  |         scoreExpressInfoMapper.insert(expressInfo); | 
 |  |  |  | 
 |  |  |         AccountInfo update = new AccountInfo(); | 
 |  |  |         update.setAccountId(accountInfo.getAccountId()); | 
 |  |  |         BigDecimal remianScore = score.subtract(totalPrice); | 
 |  |  |         update.setCollectScore(remianScore.toString()); | 
 |  |  |         accountInfoMapper.updateByPrimaryKey(update); | 
 |  |  |         BigDecimal remianScore = score.subtract(totalPrice).setScale(0, BigDecimal.ROUND_DOWN); | 
 |  |  |         accountInfo.setCollectScore(remianScore.toString()); | 
 |  |  |         accountInfoMapper.updateByPrimaryKey(accountInfo); | 
 |  |  |  | 
 |  |  |         ScoreDetails scoreDetails = new ScoreDetails(); | 
 |  |  |         scoreDetails.setOrderNo(order.getOrderNo()); | 
 |  |  | 
 |  |  |         scoreDetails.setChangeScore(totalPrice); | 
 |  |  |         scoreDetailsMapper.insert(scoreDetails); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Long cancelOrder(CancelOrderDto model) { | 
 |  |  |         /** | 
 |  |  |          * todo 只更新了订单状态,后续操作待增加 | 
 |  |  |          */ | 
 |  |  |         ScoreOrder scoreOrder = new ScoreOrder(); | 
 |  |  |         scoreOrder.setId(model.getId()); | 
 |  |  |         scoreOrder.setStatus(ScoreOrder.STATUS_CANCEL); | 
 |  |  |         scoreOrderMapper.updateByPrimaryKeySelective(scoreOrder); | 
 |  |  |         return scoreOrder.getId(); | 
 |  |  |     } | 
 |  |  | } |