|
|
@@ -0,0 +1,87 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
+ *
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
+ * this software without specific prior written permission.
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
+ */
|
|
|
+package org.springblade.gateway.goods_gatway.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.lang.UUID;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import org.springblade.common.enums.AppConstant;
|
|
|
+import org.springblade.common.enums.OrderType;
|
|
|
+import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.gateway.goods_gatway.dto.AppGoodsBillsDTO;
|
|
|
+import org.springblade.gateway.goods_gatway.service.IAppGoodsBillsService;
|
|
|
+import org.springblade.ldt.bills.entity.Bills;
|
|
|
+import org.springblade.ldt.bills.entity.GoodsBills;
|
|
|
+import org.springblade.ldt.bills.mapper.GoodsBillsMapper;
|
|
|
+import org.springblade.ldt.bills.service.IBillsService;
|
|
|
+import org.springblade.ldt.bills.service.IGoodsBillsService;
|
|
|
+import org.springblade.ldt.bills.vo.GoodsBillsVO;
|
|
|
+import org.springblade.ldt.shop.entity.Shop;
|
|
|
+import org.springblade.ldt.shop.service.IShopService;
|
|
|
+import org.springblade.ldt.user.service.ILoginUserService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.Assert;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 订单 服务实现类
|
|
|
+ *
|
|
|
+ * @author huangmp
|
|
|
+ * @since 2021-09-26
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class AppGoodsBillsServiceImpl extends BaseServiceImpl<GoodsBillsMapper, GoodsBills> implements IAppGoodsBillsService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IShopService shopService;
|
|
|
+ @Resource
|
|
|
+ private ILoginUserService loginUserService;
|
|
|
+ @Resource
|
|
|
+ private IBillsService billsService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void order(AppGoodsBillsDTO appGoodsBillsDTO) {
|
|
|
+ Shop shop = shopService.getById(appGoodsBillsDTO.getReceiveId());
|
|
|
+ Assert.notNull(shop,"找不到下单商户");
|
|
|
+ //插入订单
|
|
|
+ Bills bills = new Bills();
|
|
|
+ bills.setPayId(appGoodsBillsDTO.getPayId());
|
|
|
+ bills.setReceiveId(appGoodsBillsDTO.getReceiveId());
|
|
|
+ bills.setMallId(shop.getMallId());
|
|
|
+ //商品价格单位为分,bills账单单位为元
|
|
|
+ bills.setCost(BigDecimal.valueOf(appGoodsBillsDTO.getTotalPrice()/100));
|
|
|
+ bills.setType(OrderType.USER_PAY.name());
|
|
|
+ bills.setPayStatus(AppConstant.BillPayStatus.待付款.name());
|
|
|
+ bills.setTitle("用户订餐");
|
|
|
+ bills.setExTime(appGoodsBillsDTO.getExpireTime());
|
|
|
+ bills.setAppid(appGoodsBillsDTO.getAppId());
|
|
|
+ bills.setOpenid(loginUserService.getById(appGoodsBillsDTO.getPayId()).getOpenid());
|
|
|
+ billsService.save(bills);
|
|
|
+ //插入商品订单
|
|
|
+ appGoodsBillsDTO.setBillsId(bills.getId());
|
|
|
+ //取手机号作为取餐号
|
|
|
+ String verifyNum = StringUtil.sub(appGoodsBillsDTO.getUserPhone(), 7, 11);
|
|
|
+ appGoodsBillsDTO.setVerifyNum(Integer.valueOf(verifyNum));
|
|
|
+ appGoodsBillsDTO.setOrderStatus(AppConstant.BillPayStatus.待付款.name());
|
|
|
+ this.save(appGoodsBillsDTO);
|
|
|
+ }
|
|
|
+}
|