Quellcode durchsuchen

积分订单小票

jk-GitHub-coder vor 4 Jahren
Ursprung
Commit
c2474a098a

+ 28 - 1
YijiaRestful/src/main/java/com/platform/yijia/controller/IntegralShoppingMallController.java

@@ -1,15 +1,16 @@
 package com.platform.yijia.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
 import com.platform.yijia.pojo.*;
 import com.platform.yijia.service.*;
 import com.platform.yijia.utils.CodeMsg;
+import com.platform.yijia.utils.FeiEPrinterUtil;
 import com.platform.yijia.utils.ResultData;
 import com.platform.yijia.utils.redis.RedisCacheUtil;
 import com.platform.yijia.utils.weixinapp.WeiXinUserUtil;
 import com.platform.yijia.utils.weixinapp.WxPushUtil;
 import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
-import net.sf.json.JSONObject;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -225,6 +226,32 @@ public class IntegralShoppingMallController {
                             String templateId = "9EWrreI-P8r4xDgoOcczC4jHt1v0HEjKzkgVRDzoNXA";  //积分兑换成功通知模板
                             wxPushUtil.push(gzhAppId, gzhAppSecret, templateId, request.getOpenId(), wxMpTemplate);
                             resultData=ResultData.success(CodeMsg.SUCCESS);
+
+                            //打印机打印小票
+                            List<Map<String, Object>> stationPrinterList = stationService.getStationPrinterList(request.getStationId());
+                            if(stationPrinterList != null && stationPrinterList.get(0).get("integralPrintFlag").toString().equals("1")){
+                                if(stationPrinterList.get(0).get("printerSn") !=null){
+                                    String sn=stationPrinterList.get(0).get("printerSn").toString();
+                                    String content1;
+                                    content1 = "<CB>积分订单小票</CB><BR>";
+                                    content1 += "订单号:"+integralOrderNo+"  <BR>";
+                                    content1 += "交易时间:"+new SimpleDateFormat(" yyyy-MM-dd HH:mm:ss").format(integralOrder.getExchangeTime())+" <BR>";
+                                    content1 += "油站:"+stationName+"  <BR>";
+                                    content1 += "兑换商品:"+integralOrder.getWaresName()+"  <BR>";
+                                    content1 += "商品数量:x "+integralOrder.getExchangeNum()+"  <BR>";
+                                    content1 += "消耗积分: "+orderSumIntegral+" 分<BR>";
+                                    content1 += "剩余积分: "+surplusPoints+" 分<BR>";
+                                    //content1 += "<BOLD><B>消耗积分: "+orderSumIntegral+" 分</B></BOLD><BR>";
+                                    content1 += "客户昵称: "+integralOrder.getCustomerName()+"  <BR>";
+                                    content1 += "<BR>";
+                                    String printInfo = FeiEPrinterUtil.printReceipt(sn, content1);
+                                    com.alibaba.fastjson.JSONObject jsonObject = JSONObject.parseObject(printInfo);
+                                    if(jsonObject != null && jsonObject.getString("msg").equals("ok")){
+                                        integralOrder.setPrinterStatus("1");
+                                        integralOrderService.updateIntegralOrder(integralOrder);
+                                    }
+                                }
+                            }
                         }else {
                             resultData=ResultData.error(CodeMsg.REQUEST_FAIL);
                         }

+ 3 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/IntegralOrderMapper.java

@@ -11,4 +11,7 @@ public interface IntegralOrderMapper {
 
     //获取个人积分订单
     List<IntegralOrder> getUserIntegralOrderList(IntegralOrder integralOrder);
+
+    //更新订单
+    void updateIntegralOrder(IntegralOrder integralOrder);
 }

+ 3 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/StationInfoMapper.java

@@ -10,6 +10,9 @@ import org.apache.ibatis.annotations.Param;
 
 public interface StationInfoMapper {
 
+    //获取油站的打印机
+    List<Map<String, Object>> getStationPrinterList(Integer stationId);
+
     //获取油站轮播图片
     List<StationPic> getStationPicList (StationPic stationPic);
 

+ 1 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/IntegralOrder.java

@@ -26,4 +26,5 @@ public class IntegralOrder {
     private  Integer integral;           //订单商品单价积分
     private  Integer stationId;          //油站ID
     private  String stationName;        //'会员名称',
+    private  String printerStatus;      //是否已打印小票
 }

+ 3 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/IntegralOrderService.java

@@ -10,4 +10,7 @@ public interface IntegralOrderService {
     //获取个人积分订单
     List<IntegralOrder> getUserIntegralOrderList(IntegralOrder integralOrder);
 
+    //更新订单
+    void updateIntegralOrder(IntegralOrder integralOrder);
+
 }

+ 3 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/StationService.java

@@ -41,4 +41,7 @@ public interface StationService {
 
     //查询油站油品价格
     StationOilPrice getStationOilPrice(StationOilPrice stationOilPrice);
+
+    //获取油站的打印机
+    List<Map<String, Object>> getStationPrinterList(Integer stationId);
 }

+ 6 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/IntegralOrderServiceImpl.java

@@ -13,6 +13,12 @@ public class IntegralOrderServiceImpl implements IntegralOrderService {
     @Resource
     private IntegralOrderMapper integralOrderMapper;
 
+    //更新订单
+    @Override
+    public void updateIntegralOrder(IntegralOrder integralOrder) {
+        integralOrderMapper.updateIntegralOrder(integralOrder);
+    }
+
     //新增积分订单
     @Override
     public boolean insertIntegralOrder(IntegralOrder integralOrder) {

+ 6 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/StationServiceImpl.java

@@ -28,6 +28,12 @@ public class StationServiceImpl implements StationService {
     @Resource
     private StationOilPriceMapper stationOilPriceMapper;
 
+    //获取油站的打印机
+    @Override
+    public List<Map<String, Object>> getStationPrinterList(Integer stationId) {
+        return stationInfoMapper.getStationPrinterList(stationId);
+    }
+
     //查询油站油品价格
     @Override
     public StationOilPrice getStationOilPrice(StationOilPrice stationOilPrice) {

+ 24 - 0
YijiaRestful/src/main/resources/mapper/IntegralOrderMapper.xml

@@ -17,6 +17,7 @@
     <result column="status"             jdbcType="VARCHAR"      property="status" />
     <result column="integral"           jdbcType="INTEGER"      property="integral" />
     <result column="station_id"         jdbcType="INTEGER"      property="stationId" />
+    <result column="printer_status"     jdbcType="VARCHAR"      property="printerStatus" />
   </resultMap>
 
   <!--查询列-->
@@ -41,6 +42,23 @@
     ORDER BY exchange_time DESC
   </select>
 
+  <!-- 更新积分订单-->
+  <update id="updateIntegralOrder" parameterType="com.platform.yijia.pojo.IntegralOrder">
+    UPDATE
+        integral_order
+    <set>
+      <if test="printerStatus !=null">
+        printer_status = #{printerStatus},
+      </if>
+    </set>
+    <where>
+      <if test="integralOrderNo !=null and integralOrderNo != ''">
+        integral_order_no = #{integralOrderNo}
+      </if>
+    </where>
+  </update>
+
+
   <!--新增积分订单-->
   <insert id="insertIntegralOrder" parameterType="com.platform.yijia.pojo.IntegralOrder">
     INSERT INTO integral_order
@@ -87,6 +105,9 @@
       <if test="stationName !=null">
         station_name,
       </if>
+      <if test="printerStatus !=null">
+        printer_status,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="integralOrderNo !=null">
@@ -131,6 +152,9 @@
       <if test="stationName !=null">
         #{stationName},
       </if>
+      <if test="printerStatus !=null">
+        #{printerStatus},
+      </if>
     </trim>
   </insert>
 

+ 23 - 7
YijiaRestful/src/main/resources/mapper/StationInfoMapper.xml

@@ -484,14 +484,14 @@
   <!--查询油站轮播图片信息-->
   <select id="getStationPicList" resultMap="StationPicResultMap" parameterType="com.platform.yijia.pojo.StationPic">
     SELECT
-    id,
-    name,
-    url,
-    station_id,
-    station_name,
-    parent_id
+        id,
+        name,
+        url,
+        station_id,
+        station_name,
+        parent_id
     FROM
-    station_pic
+        station_pic
     <where>
       <if test="stationId !=null and stationId !=''">
         AND station_id = #{stationId}
@@ -499,5 +499,21 @@
     </where>
   </select>
 
+  <!--根据油站Id油枪号获取打印机编号 -->
+  <select id="getStationPrinterList" parameterType="Integer" resultType="Map">
+    SELECT
+        A.station_id                AS stationId,
+        A.device_no                 AS printerSn,
+        B.integral_print_flag       AS integralPrintFlag
+    FROM  station_device_manage     AS A
+        LEFT JOIN station_pay       AS B ON A.station_id = B.station_id
+    <where>
+      A.device_status = "1"
+      <if test="stationId != null and stationId !=''">
+        AND A.station_id = #{stationId}
+      </if>
+    </where>
+  </select>
+
 
 </mapper>