ソースを参照

8.4 二级市场创建订单相关

Mechrevo 2 年 前
コミット
1e151a0247

+ 114 - 0
sp-core/sp-base/src/main/java/com/pj/aliyun/sms/AliyunInformSmsService.java

@@ -0,0 +1,114 @@
+package com.pj.aliyun.sms;
+
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.http.MethodType;
+import com.aliyuncs.profile.DefaultProfile;
+import com.aliyuncs.profile.IClientProfile;
+import lombok.extern.log4j.Log4j2;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 阿里云通知短信
+ * @Author Mechrevo
+ * @Date 2023 08 04 09 47
+ **/
+@Slf4j
+public class AliyunInformSmsService {
+
+
+    // 签名
+    private static final String signName = "某某公司";
+
+    // 模板
+    private static final String templateCode = "SMS_22*****04";
+
+    // 阿里云短信配置信息
+    private static final String accessKeyId = "LTA*************9Cf";
+    private static final String accessKeySecret = "1GjBfyf*****************SDlP";
+    private static final String REGION_ID = "cn-hangzhou";
+    private static final String PRODUCT = "Dysmsapi";
+    private static final String DOMAIN = "dysmsapi.aliyuncs.com";
+
+    /**
+     * 发送短信通知
+     *
+     * @param mobile 手机号
+     * @return 执行结果
+     */
+    public static boolean sendSMS(String mobile) {
+        try {
+            IClientProfile profile = DefaultProfile.getProfile(REGION_ID, accessKeyId, accessKeySecret);
+
+            DefaultProfile.addEndpoint(REGION_ID, REGION_ID, PRODUCT, DOMAIN);
+
+            IAcsClient acsClient = new DefaultAcsClient(profile);
+
+            SendSmsRequest request = new SendSmsRequest();
+
+            request.setMethod(MethodType.POST);
+
+            // 手机号可以单个也可以多个(多个用逗号隔开,如:15*******13,13*******27,17*******56)
+            request.setPhoneNumbers(mobile);
+
+            request.setSignName(signName);
+
+            request.setTemplateCode(templateCode);
+
+            /*  例如签名内容为:某某公司
+            例如模板内容为:亲爱的同事,很高兴的通知您,您抽中了由领导${userName}派发的大饼奖励${money}元,请及时找财务领取!
+            变量属性:userName-其他;money-其他;
+            则短信内容为:【某某公司】 亲爱的同事,很高兴的通知您,您抽中了由领导${userName}派发的大饼奖励${money}元,请及时找财务领取!*/
+            request.setTemplateParam("{\"mobile\":\""+ mobile +"\",\"mobile\":\""+ mobile +"\"}");
+
+            SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
+            if ((sendSmsResponse.getCode() != null) && (sendSmsResponse.getCode().equals("OK"))) {
+                log.info("发送成功,code:" + sendSmsResponse.getCode());
+                return true;
+            } else {
+                log.info("发送失败,code:" + sendSmsResponse.getCode());
+                return false;
+            }
+        } catch (ClientException e) {
+            log.error("发送失败,系统错误!", e);
+            return false;
+        }
+    }
+
+    /**
+     * 获取逗号分隔的拼接字符串
+     *
+     * @param str 用于拼接的字符串集合
+     * @return String
+     */
+    public static String getSplitString(List<String> str) {
+        StringBuilder newS = new StringBuilder();
+        if (str != null && str.size() > 0) {
+            for (String s : str) {
+                newS.append(s).append(",");
+            }
+        }
+        if (newS.length() > 0)
+            newS.deleteCharAt(newS.length() - 1);// 删除最后一个多余的逗号
+        return newS.toString();
+    }
+
+    public static void main(String[] args) {
+//        多发
+//        List<String> mobiles = new ArrayList<>();
+//        mobiles.add("15*******13");
+//        mobiles.add("13*******27");
+//        mobiles.add("17*******56");
+//        String s= getSplitString(mobiles);
+//        System.out.println(AliyunInformSmsService.sendSMS(s, "大老鼠",  -2000L));
+//         单发
+        System.out.println(AliyunInformSmsService.sendSMS("177******56"));
+    }
+
+}

+ 1 - 0
sp-core/sp-base/src/main/java/com/pj/aliyun/sms/AliyunSmsService.java

@@ -21,6 +21,7 @@ import java.util.Random;
 import java.util.concurrent.TimeUnit;
 
 /**
+ * 阿里云验证码短信
  * Created on 17/6/7.
  * 短信API产品的DEMO程序,工程中包含了一个SmsDemo类,直接通过
  * 执行main函数即可体验短信产品API功能(只需要将AK替换成开通了云通信-短信产品功能的AK即可)

+ 7 - 8
sp-core/sp-base/src/main/java/com/pj/retry/SmsRetryService.java

@@ -1,5 +1,6 @@
 package com.pj.retry;
 
+import com.pj.aliyun.sms.AliyunInformSmsService;
 import com.pj.aliyun.sms.AliyunSmsService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.retry.annotation.Backoff;
@@ -27,28 +28,26 @@ public class SmsRetryService {
      */
     @Async
     @Retryable(value = Exception.class,maxAttempts = 3,backoff = @Backoff(delay = 2000,multiplier = 1.5))
-    public boolean sendSms(String phone,String code) throws Exception {
+    public boolean sendSmsCode(String phone,String code) throws Exception {
         //模拟发送失败
         //todo: 发送短信业务逻辑
-
-        throw new Exception("模拟短信发送失败!");
+        boolean result = AliyunSmsService.sendSms("18934859524", "Mechrevo", "SMS_462415029", null);
+        if(!result) throw new Exception("模拟短信发送失败!");
+        return true;
     }
 
     /**
      * 通知短信
      * @param phone
-     * @param signName
-     * @param templateCode
-     * @param jsonString
      * @return
      * @throws Exception
      */
     @Async
     @Retryable(value = Exception.class,maxAttempts = 3,backoff = @Backoff(delay = 2000,multiplier = 1.5))
-    public boolean sendSmsMsg(String phone,String signName,String templateCode,String jsonString) throws Exception {
+    public boolean sendSmsMsg(String phone) throws Exception {
         System.out.println("\n发送通知短信!\n");
         //todo: 发送短信业务逻辑
-        boolean result = AliyunSmsService.sendSms("18934859524", "Mechrevo", "SMS_462415029", null);
+        boolean result = AliyunInformSmsService.sendSMS("18934859524");
         if(!result) throw new Exception("模拟短信发送失败!");
         return true;
     }

+ 3 - 3
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseService.java

@@ -194,10 +194,10 @@ public class TbEnterpriseService extends ServiceImpl<TbEnterpriseMapper, TbEnter
 		//获取当前登录用户
 		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
 		if(appLoginInfo == null || appLoginInfo.getLoginId() == null)throw new RuntimeException("当前登陆用户信息已失效!");
-		Long loginId = appLoginInfo.getLoginId();
+		Long fk = appLoginInfo.getFk();
 		//仅能查询自己的订单
-		so.set("buy_user_id",loginId);
-		so.set("delete_status",DeleteStatus.DELETE_STATUS_ON.getCode());
+		so.set("buyUserId",fk);
+		so.set("deleteStatus",DeleteStatus.DELETE_STATUS_ON.getCode());
 		so.set("keyword",keyword);
 
 		List<TbOrder> tbOrders = tbOrderMapper.getList(so);

+ 1 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/GoodsTransitAppController.java

@@ -46,7 +46,7 @@ public class GoodsTransitAppController {
         if(appLoginInfo == null)throw new RuntimeException("当前登陆用户信息已失效!");
 
         SoMap so = SoMap.getRequestSoMap();
-        so.put("merchantId",appLoginInfo.getLoginId());
+        so.put("merchantId",appLoginInfo.getFk());
         so.put("deleteStatus" , DeleteStatus.DELETE_STATUS_ON.getCode());
         List<TbGoodsTransit> list = tbGoodsTransitService.getList(so.startPage());
         return AjaxJson.getPageData(so.getDataCount(), list);

+ 1 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/MethodGoodsTransitService.java

@@ -41,7 +41,6 @@ public class MethodGoodsTransitService {
     private TbOrderMapper tbOrderMapper;
     @Autowired
     private TbPeopleMapper tbPeopleMapper;
-    //todo:
 
 
 
@@ -73,7 +72,7 @@ public class MethodGoodsTransitService {
                 enterpriseList.forEach(item -> {
                     //todo: 给边民发送短信,调用短信商接口API
                     try {
-                        smsRetryService.sendSms(item.getPhone(), item.getCode().equals("null")? "666666" :item.getCode());
+                        smsRetryService.sendSmsCode(item.getPhone(), "666");
                     } catch (Exception e) {
                         System.out.println("异常被抓住了!");
                         throw new RuntimeException(e);

+ 4 - 20
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitService.java

@@ -245,7 +245,8 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
 			throw new RuntimeException("当前登陆用户信息已失效!");
 		//判断当前登陆人是否为互市组组长
 		List<TbPeople> list = tbPeopleMapper.selectList
-				(new LambdaQueryWrapper<TbPeople>().eq(TbPeople::getId,appLoginInfo.getFk()).eq(TbPeople::getRole, 2)
+				(new LambdaQueryWrapper<TbPeople>().eq(TbPeople::getId,appLoginInfo.getFk())
+						.eq(TbPeople::getRole, 2) // 1 边民 2组长
 						.eq(TbPeople::getIsLock, IsLock.IS_LOCK_ON.getCode())
 						.eq(TbPeople::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode()));
 		if(list.size() != 1)throw new RuntimeException("您当前不属于互市组组长~");
@@ -272,30 +273,13 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
 				//获取商家信息
 				TbEnterprise tbEnterprise = tbEnterpriseMapper.selectById(tbGoodsTransit.getMerchantId());
 				if(tbEnterprise == null)throw new RuntimeException("商家不存在!");
-				//todo: 线上时放开下面的参数
-				return smsRetryService.sendSmsMsg("","","","");
+				//todo: 线上时放开下面的参数 - 通知短信
+				return smsRetryService.sendSmsMsg("18934859524");
 //				("18934859524", "一天实验室服务", "SMS_257813081", JSONUtils.toJSONString("修改内容"));
 			}
 		}
 		throw new RuntimeException("订单预创建异常!");
 	}
-	/**
-	 * 	// todo: 执行订单完成后的逻辑
-	 * 			// todo: 发送短信给边民组通知其确认
-	 * 			//获取互市组ID
-	 * 			Long groupId = list.get(0).getGroupId();
-	 * 			if(groupId == null)throw new RuntimeException("订单异常,原因是没有关联的边民!");
-	 * 			//通过互市组ID查询所属边民的ID集合
-	 * 			List<TbPeople> tbPeopleList = tbPeopleMapper.selectList
-	 * 					(new LambdaQueryWrapper<TbPeople>()
-	 * 							.eq(TbPeople::getGroupId, groupId)
-	 * 							.eq(TbPeople::getIsLock, IsLock.IS_LOCK_ON.getCode())
-	 * 							.eq(TbPeople::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode()));
-	 *
-	 * 			if(tbPeopleList.size() == 0)throw new RuntimeException("订单异常,原因是没有关联的边民!!!");
-	 * 			int sendSmsCounts = methodGoodsTransitService.sendSms(tbPeopleList);
-	 * 			return sendSmsCounts == tbPeopleList.size();
-	 */
 
 
 	/**

+ 0 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderAppController.java

@@ -54,7 +54,6 @@ public class TbOrderAppController {
 	public AjaxJson updateResaleStatus(Long orderId) {
 		boolean result = tbOrderService.updateResaleStatus(orderId);
 		if(result) return AjaxJson.getSuccess();
-
 		return AjaxJson.getError();
 	}
 

+ 10 - 1
sp-service/level-two-server/src/main/java/com/pj/tb_demand_quotation/TbDemandQuotation.java

@@ -61,11 +61,20 @@ public class TbDemandQuotation extends Model<TbDemandQuotation> implements Seria
 	 * 组名称 
 	 */
 	private String groupName;	
+	/**
+	 *  联系电话
+	 */
+	private String linkPhone;
 
 	/**
 	 * 二级市场收购商需求表ID 
 	 */
-	private Long demandId;	
+	private Long demandId;
+
+	/**
+	 * 二级市场收购商需求表ID
+	 */
+	private Long trade_area_id;
 
 	/**
 	 * 报价(CNY) 

+ 2 - 2
sp-service/level-two-server/src/main/java/com/pj/tb_demand_quotation/TbDemandQuotationService.java

@@ -106,8 +106,8 @@ public class TbDemandQuotationService extends ServiceImpl<TbDemandQuotationMappe
 			tbGoodsDemand.setIsOrders(demandQuotationParam.getIsOrders());
 			int updateById = tbGoodsDemandMapper.updateById(tbGoodsDemand);
 			if(updateById != 1)throw new RuntimeException("无法进行报价!");
-			//短信提示二级市场收购商,需求已报价,进入app进行确认接单 todo:该位置需打开
-			return smsRetryService.sendSmsMsg(null,null,null,null);
+			//短信提示二级市场收购商,需求已报价,进入app进行确认接单 todo:该位置需打开 - 通知短信
+			return smsRetryService.sendSmsMsg(null);
 		}
 			throw new RuntimeException("抢单报价失败!");
 //		return true;

+ 19 - 5
sp-service/level-two-server/src/main/java/com/pj/tb_goods_demand/MethodGoodsDemandService.java

@@ -10,6 +10,7 @@ import com.pj.tb_demand_quotation.TbDemandQuotation;
 import com.pj.tb_demand_quotation.TbDemandQuotationMapper;
 import com.pj.tb_demand_quotation.TbDemandQuotationService;
 import com.pj.tb_goods_demand.vo.GoodsDemandVo;
+import com.pj.tb_orders.TbOrders;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -79,19 +80,32 @@ public class MethodGoodsDemandService {
 
     /**
      * 执行同意处理
-     * @param goodsDemandId
-     * @param demandQuotationId
+     * @param goodsDemandId 需求表ID
+     * @param demandQuotationId  报价表ID
+     * @param disposeStatus 处理状态 1=确认,2=拒绝
      */
-    public void agreeQuotation(Integer disposeStatus,Long goodsDemandId,Long demandQuotationId) throws Exception {
+    public void agreeQuotation(Integer disposeStatus,Long goodsDemandId,Long demandQuotationId){
         // 校验参数
-        TbDemandQuotation tbDemandQuotation = tbDemandQuotationMapper.selectById(demandQuotationId);
+        TbDemandQuotation tbDemandQuotation = tbDemandQuotationMapper.selectById(demandQuotationId); // 报价
         if(tbDemandQuotation == null)return;
-        TbGoodsDemand tbGoodsDemand = tbGoodsDemandMapper.selectById(goodsDemandId);
+        TbGoodsDemand tbGoodsDemand = tbGoodsDemandMapper.selectById(goodsDemandId); //需求
         if(tbGoodsDemand == null)return;
         //执行过程
         tbDemandQuotation.setQuotationResult(disposeStatus);
         int updateById = tbDemandQuotationMapper.updateById(tbDemandQuotation);
+        if(updateById == 1){
+            //开始创建订单
+            TbOrders tbOrders = new TbOrders();
+            //设置订单基本属性
+            tbOrders.setGoodsId(tbGoodsDemand.getLevelOneGoodsId()); //一级市场海关允许销售商品表ID
+            tbOrders.setGoodsName(tbGoodsDemand.getGoodsName());
+//            tbOrders.setGoodsFrom();  //产地
+            tbOrders.setShipperPhone(tbDemandQuotation.getLinkPhone()); //联系电话
+            tbOrders.setShipperName(tbDemandQuotation.getCreateName()); //卖家名称
+
+
 
+        }
 
     }
                 //  todo: ----------------

+ 4 - 4
sp-service/level-two-server/src/main/java/com/pj/tb_goods_demand/TbGoodsDemandService.java

@@ -77,9 +77,9 @@ public class TbGoodsDemandService extends ServiceImpl<TbGoodsDemandMapper, TbGoo
 		if(appLoginInfo == null || appLoginInfo.getLoginId() == null)
 			throw new ServiceException("当前登录账号信息已失效!");
 		//匹配已被报价的列表
-		so.set("purchaser_id",appLoginInfo.getFk());
-		so.set("is_orders",isOrders);
-		so.set("delete_status",DeleteStatus.DELETE_STATUS_ON.getCode());
+		so.set("purchaserId",appLoginInfo.getFk());
+		so.set("isOrders",isOrders);
+		so.set("deleteStatus",DeleteStatus.DELETE_STATUS_ON.getCode());
 		List<TbGoodsDemand> goodsDemandMapperList = tbGoodsDemandMapper.getList(so);
 		if(goodsDemandMapperList.size() != 0){
 			List<GoodsDemandVo> goodsDemandVos = methodGoodsDemandService.setGoodsDemandVo(goodsDemandMapperList);
@@ -94,7 +94,7 @@ public class TbGoodsDemandService extends ServiceImpl<TbGoodsDemandMapper, TbGoo
 	 * @param goodsDemandId  需求表主键
 	 * @param demandQuotationId 报价表主键
 	 */
-	public void disposeOrders(Integer disposeStatus,Long goodsDemandId,Long demandQuotationId) throws Exception {
+	public void disposeOrders(Integer disposeStatus,Long goodsDemandId,Long demandQuotationId)  {
 		//获取并判断当前登陆人
 		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
 		if(appLoginInfo == null || appLoginInfo.getLoginId() == null)

+ 2 - 1
sp-service/transport-server/src/main/java/com/pj/project/tb_driver/TbDriverController.java

@@ -4,6 +4,7 @@ import java.io.IOException;
 import java.util.List;
 
 import com.pj.api.dto.DriverDto;
+import com.pj.enummj.DeleteStatus;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -74,7 +75,7 @@ public class TbDriverController {
 		@SaCheckPermission(TbDriver.PERMISSION_CODE)
 	public AjaxJson getList() { 
 		SoMap so = SoMap.getRequestSoMap();
-		so.set("deleteStatus", 1);
+		so.put("deleteStatus", DeleteStatus.DELETE_STATUS_ON.getCode());
 		List<TbDriver> list = tbDriverService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}