Pārlūkot izejas kodu

订单支付方式更新

LiRong 3 nedēļas atpakaļ
vecāks
revīzija
797872e437

+ 6 - 3
leromro-admin/src/main/resources/application.yml

@@ -143,8 +143,11 @@ xss:
   urlPatterns: /system/*,/monitor/*,/tool/*
 wx:
   url: https://api.weixin.qq.com
-  app-id: wxf8cc1f7fffc41354
-  secret: 36a6c5c2148e1c16a33a59279fed0378
+ # app-id: wxf8cc1f7fffc41354
+ # secret: 36a6c5c2148e1c16a33a59279fed0378
   # 我的
  # app-id: wxd757c9902b8d10d9
- # secret: 8743a3bc9611c8d145d2679141e58dd4
+ # secret: 8743a3bc9611c8d145d2679141e58dd4
+  #正式的
+  app-id: wxe8a05852410396cf
+  secret: ea6531db3d1a1d816343c41604642fea

+ 1 - 1
leromro-core/src/main/java/com/leromro/core/controller/OrdersController.java

@@ -113,7 +113,7 @@ public class OrdersController extends BaseController {
     /**
      * 用户点击完成订单 , 根据评价算钱。
      */
-    @ApiOperation(value = "用户评价小订单",notes = "传入对象参数 包含: seconderId, 四个score, userReview, userPicture")
+    @ApiOperation(value = "用户评价小订单",notes = "传入对象参数 包含: secondOrderId, 四个score, userReview, userPicture")
     @PostMapping("/userFinishOrder")
     public AjaxResult userFinish (@RequestBody UserOrderReviewDTO reviewDTO) {
 

+ 26 - 17
leromro-core/src/main/java/com/leromro/core/service/impl/MainOrderServiceImpl.java

@@ -15,6 +15,7 @@ import com.leromro.core.utils.DateTimeUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.time.Duration;
@@ -60,45 +61,53 @@ public class MainOrderServiceImpl extends ServiceImpl<MainOrdersMapper, MainOrde
      * @param orderRequest
      */
     @Override
+    @Transactional
     /*@Transactional*/
     public void createOrders(OrderRequestDTO orderRequest) {
         MainOrders orders = orderRequest.getOrders();
         List<VolunteerWorkDate> workDateList = orderRequest.getWorkDateList();
         Long userId = SecurityUtils.getUserId();
-        //把地址信息也添加到数据里面
-        Address address = addressMapper.selectAddressByAddressId(orders.getAddressId());
-        orders.setAddress(address.getAddress());
-        orders.setClientName(address.getName());
-        orders.setClientTelephone(address.getTelephone());
+
         //获取志愿者信息,同时服务时长和价格也都在志愿者id中进行获取
         VolunteerInfo info = volunteerInfoMapper.selectOne(new LambdaQueryWrapper<VolunteerInfo>()
                 .eq(VolunteerInfo::getVolunteerInfoId, orders.getVolunteerInfoId()));
         BigDecimal serviceOnePrice = info.getBusinessPrice();
         Integer businessDurationMin = info.getBusinessDuration();
+        // 判断支付方式,余额扣减余额。 1 余额 2 微信
+        if (orders.getPaymentMethod().equals("1")){
+            // 查看余额够不够  修改用户余额表
+            BigDecimal totalPrice = orders.getServiceTotalPrice();
+            ClientAccount clientAccount = clientAccountMapper.selectBalanceByuserID(userId);
+            BigDecimal balanceOld = clientAccount.getBalance();
+            int compared = totalPrice.compareTo(balanceOld);
+            if (compared>0){
+                throw new RuntimeException("余额不足,支付失败");
+            }else {
+                BigDecimal balanceNew = balanceOld.subtract(totalPrice);
+                clientAccount.setBalance(balanceNew);
+                clientAccountMapper.updateClientBalance(clientAccount);
+            }
+        }else if (orders.getPaymentMethod().equals("2")){
+            //待完成 微信支付
+            System.out.println("微信支付");
 
-        // 查看余额够不够  修改用户余额表
-        BigDecimal totalPrice = orders.getServiceTotalPrice();
-        ClientAccount clientAccount = clientAccountMapper.selectBalanceByuserID(userId);
-        BigDecimal balanceOld = clientAccount.getBalance();
-        int compared = totalPrice.compareTo(balanceOld);
-        if (compared>0){
-            throw new RuntimeException("余额不足,支付失败");
         }else {
-            BigDecimal balanceNew = balanceOld.subtract(totalPrice);
-            clientAccount.setBalance(balanceNew);
-            clientAccountMapper.updateClientBalance(clientAccount);
+            throw new RuntimeException("支付方式错误");
         }
         //创建订单主表
+        //把地址信息也添加到数据里面
+        Address address = addressMapper.selectAddressByAddressId(orders.getAddressId());
+        orders.setAddress(address.getAddress());
+        orders.setClientName(address.getName());
+        orders.setClientTelephone(address.getTelephone());
         long orderId = snowflake.nextId();
         orders.setMainOrderId(String.valueOf(orderId));
         orders.setOrderStatus("1");
         orders.setFinishTimes(0L);
-        orders.setPaymentMethod("0");
         orders.setUserId(userId);
         orders.setCreateTime(DateTimeUtil.getNowTime());
         orders.setServiceOnePrice(serviceOnePrice);
         orders.setServiceDuration(businessDurationMin);
-//        mainOrdersMapper.insertMainOrders(orders);
         this.save(orders);
 
         //修改志愿者预约时间表

+ 1 - 1
leromro-core/src/main/resources/mapper/core/AddressMapper.xml

@@ -65,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select * from l_address where address_id = (select address_id from l_second_order where second_order_id = #{orderId});
     </select>
     <select id="selectAddressList" resultType="com.leromro.core.domain.Address" parameterType="java.lang.Long">
-        <include refid="selectAddressVo"/>
+        select * from l_address
         <where>
             <if test="userId != null "> and user_id = #{userId}</if>
         </where>