Browse Source

店铺维护功能

wangxiaoming 5 years ago
parent
commit
f9b2176d5f

+ 51 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/cm/StoreInfo.java

@@ -19,6 +19,17 @@ public class StoreInfo implements Serializable {
     private Date storeCreateTime;   //创建时间
     private CompanyInfo companyInfo;
 
+    //发货人姓名
+    private String storeShipName;
+    //发货人电话号码
+    private String storeShipTel;
+    //发货人省份
+    private String storeShipProvince;
+    //发货人城市
+    private String storeShipCity;
+    //发货人地址
+    private String storeShipAddress;
+
     public CompanyInfo getCompanyInfo() {
         return companyInfo;
     }
@@ -82,4 +93,44 @@ public class StoreInfo implements Serializable {
     public void setStoreCreateTime(Date storeCreateTime) {
         this.storeCreateTime = storeCreateTime;
     }
+
+    public String getStoreShipName() {
+        return storeShipName;
+    }
+
+    public void setStoreShipName(String storeShipName) {
+        this.storeShipName = storeShipName;
+    }
+
+    public String getStoreShipTel() {
+        return storeShipTel;
+    }
+
+    public void setStoreShipTel(String storeShipTel) {
+        this.storeShipTel = storeShipTel;
+    }
+
+    public String getStoreShipProvince() {
+        return storeShipProvince;
+    }
+
+    public void setStoreShipProvince(String storeShipProvince) {
+        this.storeShipProvince = storeShipProvince;
+    }
+
+    public String getStoreShipCity() {
+        return storeShipCity;
+    }
+
+    public void setStoreShipCity(String storeShipCity) {
+        this.storeShipCity = storeShipCity;
+    }
+
+    public String getStoreShipAddress() {
+        return storeShipAddress;
+    }
+
+    public void setStoreShipAddress(String storeShipAddress) {
+        this.storeShipAddress = storeShipAddress;
+    }
 }

+ 49 - 2
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/StoreInfoServiceImpl.java

@@ -1,10 +1,13 @@
 package com.iamberry.rst.service.cm;
 
 import com.iamberry.rst.core.cm.StoreInfo;
+import com.iamberry.rst.core.cm.StoreShip;
 import com.iamberry.rst.faces.cm.StoreInfoService;
 import com.iamberry.rst.service.cm.mapper.StoreInfoMapper;
+import com.iamberry.rst.service.cm.mapper.StoreShipMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -16,6 +19,8 @@ public class StoreInfoServiceImpl implements StoreInfoService {
 
     @Autowired
     private StoreInfoMapper storeInfoMapper;
+    @Autowired
+    private StoreShipMapper storeShipMapper;
 
     @Override
     public List<StoreInfo> listStore(StoreInfo storeInfo) {
@@ -33,12 +38,54 @@ public class StoreInfoServiceImpl implements StoreInfoService {
     }
 
     @Override
+    @Transactional
     public Integer updateStoreInfo(StoreInfo storeInfo) {
-        return storeInfoMapper.updateStoreInfo(storeInfo);
+        Integer flag = 0;
+        flag = storeInfoMapper.updateStoreInfo(storeInfo);
+        if(flag < 1){
+            throw new RuntimeException("修改店铺失败");
+        }
+        if(storeInfo.getStoreStatus() != null){
+            return flag;
+        }
+
+        StoreShip storeShip = new StoreShip();
+        storeShip.setStoreId(storeInfo.getStoreId());
+        List<StoreShip> storeShipList = storeShipMapper. getStoreShipList(storeShip);
+        storeShip = storeShipList.get(0);
+        storeShip.setStoreId(storeInfo.getStoreId());
+        storeShip.setStoreShipName(storeInfo.getStoreShipName());
+        storeShip.setStoreShipTel(storeInfo.getStoreShipTel());
+        storeShip.setStoreShipProvince(storeInfo.getStoreShipProvince());
+        storeShip.setStoreShipCity(storeInfo.getStoreShipCity());
+        storeShip.setStoreShipAddress(storeInfo.getStoreShipAddress());
+        flag = storeShipMapper.update(storeShip);
+        if(flag < 1){
+            throw new RuntimeException("修改店铺关联的发货信息失败");
+        }
+        return flag;
     }
 
     @Override
+    @Transactional
     public Integer addStoreInfo(StoreInfo storeInfo) {
-        return storeInfoMapper.addStoreInfo(storeInfo);
+        Integer flag = 0;
+        flag = storeInfoMapper.addStoreInfo(storeInfo);
+        if(flag < 1){
+            throw new RuntimeException("添加店铺失败");
+        }
+
+        StoreShip storeShip = new StoreShip();
+        storeShip.setStoreId(storeInfo.getStoreId());
+        storeShip.setStoreShipName(storeInfo.getStoreShipName());
+        storeShip.setStoreShipTel(storeInfo.getStoreShipTel());
+        storeShip.setStoreShipProvince(storeInfo.getStoreShipProvince());
+        storeShip.setStoreShipCity(storeInfo.getStoreShipCity());
+        storeShip.setStoreShipAddress(storeInfo.getStoreShipAddress());
+        flag = storeShipMapper.save(storeShip);
+        if(flag < 1){
+            throw new RuntimeException("添加店铺关联的发货信息失败");
+        }
+        return flag;
     }
 }

+ 10 - 4
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/mapper/storeInfoMapper.xml

@@ -17,9 +17,15 @@
   <!-- 根据id查询店铺信息 -->
   <select id="getStoreInfoById" resultType="StoreInfo" parameterType="java.lang.Integer" >
     select 
-    <include refid="storeInfo" />
-    from tb_rst_store_info
-    where store_id = #{storeId,jdbcType=INTEGER}
+      si.store_id, si.company_id, si.store_efast, si.store_name, si.store_status, si.store_remark, si.store_create_time,
+      ss.store_ship_name,
+      ss.store_ship_tel,
+      ss.store_ship_province,
+      ss.store_ship_city,
+      ss.store_ship_address
+    from tb_rst_store_info si
+    LEFT JOIN  tb_rst_store_ship ss ON si.store_id = ss.store_id
+    where si.store_id = #{storeId,jdbcType=INTEGER}
   </select>
 
   <!-- 根据efastid查询店铺信息 -->
@@ -53,7 +59,7 @@
   </select>
 
   <!-- 添加店铺信息 -->
-  <insert id="addStoreInfo" parameterType="StoreInfo" >
+  <insert id="addStoreInfo" parameterType="StoreInfo"  useGeneratedKeys="true"  keyProperty="storeId">
     insert into tb_rst_store_info (store_id, company_id, store_efast, 
       store_name, store_status, store_remark, 
       store_create_time)

+ 20 - 2
watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AdminSalesOrderController.java

@@ -1318,19 +1318,37 @@ public class AdminSalesOrderController {
     }
 
     @RequestMapping("/addStoreInfoUI")
-    @RequiresPermissions("salesOrder:listStoreInfo")
+    @RequiresPermissions("salesOrder:store:add")
     public ModelAndView addStoreInfoUI() {
         return new ModelAndView("order/store/add").addObject("list", companyInfoService.listCompanyInfo(new CompanyInfo()));
     }
+    @RequestMapping("/updateStoreInfoUI")
+    @RequiresPermissions("salesOrder:store:update")
+    public ModelAndView updateStoreInfoUI(Integer storeId) {
+        ModelAndView mv = new ModelAndView("order/store/update");
+        mv.addObject("list", companyInfoService.listCompanyInfo(new CompanyInfo()));
+
+        StoreInfo storeInfo = storeInfoService.getStoreInfoById(storeId);
+        mv.addObject("storeInfo",storeInfo);
+        return mv;
+    }
 
     @ResponseBody
     @RequestMapping("/addStoreStatus")
-    @RequiresPermissions("salesOrder:listStoreInfo")
+    @RequiresPermissions("salesOrder:store:add")
     public ResponseJson addStoreStatus(StoreInfo storeInfo) {
         Integer res = storeInfoService.addStoreInfo(storeInfo);
         return res <= 0 ? ResponseJson.getFAILURE() : ResponseJson.getSUCCESS();
     }
 
+    @ResponseBody
+    @RequestMapping("/updateStoreInfo")
+    @RequiresPermissions("salesOrder:store:update")
+    public ResponseJson updateStoreInfo(StoreInfo storeInfo) {
+        Integer res = storeInfoService.updateStoreInfo(storeInfo);
+        return res <= 0 ? ResponseJson.getFAILURE() : ResponseJson.getSUCCESS();
+    }
+
     /**
      * 删除订单
      * @param id

+ 37 - 1
watero-rst-web/src/main/webapp/WEB-INF/views/order/store/add.ftl

@@ -44,9 +44,45 @@
         </div>
 
         <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>发货人名称:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeShipName" name="storeShipName" datatype="s1-30" nullmsg="不能为空" value="爱贝源">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>发货人电话号码:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeShipTel" name="storeShipTel" datatype="s1-30" nullmsg="不能为空" value="18929377976">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>发货人省份:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeShipProvince" name="storeShipProvince" datatype="s1-30" nullmsg="不能为空" value="广东省">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>发货人城市:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeShipCity" name="storeShipCity" datatype="s1-30" nullmsg="不能为空" value="东莞市">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>发货人地址:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeShipAddress" name="storeShipAddress" datatype="s1-30" nullmsg="不能为空" value="东莞清溪三中金龙工业区优尼雅电子科技">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+
+        <div class="row cl">
             <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>备注信息:</label>
             <div class="formControls col-xs-8 col-sm-9">
-                <input type="text" class="input-text" id="storeRemark" name="storeRemark" datatype="s1-30" nullmsg="不能为空">
+                <input type="text" class="input-text" id="storeRemark" name="storeRemark" >
             </div>
             <div class="col-4"> </div>
         </div>

+ 8 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/order/store/list.ftl

@@ -44,6 +44,7 @@
                 <td><#if o.storeStatus == 1>启用<#else>禁用</#if></td>
                 <td>${o.storeCreateTime?string("yyyy-MM-dd")}</td>
                 <td class="td-manage">
+                    <a title="修改" href="javascript:edit_info(${o.storeId})" class="ml-5" style="color: blue;text-decoration:none">修改</a>
                     <#if o.storeStatus == 1>
                         <a title="禁用" href="javascript:edit_status(${o.storeId}, 2)" class="ml-5" style="color: blue;text-decoration:none">禁用</a>
                     <#else>
@@ -66,5 +67,12 @@
             window.location.reload();
         }) ;
     }
+
+    /**
+     * 修改
+     */
+    function edit_info(id) {
+        layer_show('添加店铺', '${path}/admin/salesOrder/updateStoreInfoUI?storeId='+id,'800','600')
+    }
 </script>
 </html>

+ 232 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/order/store/update.ftl

@@ -0,0 +1,232 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="renderer" content="webkit|ie-comp|ie-stand">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
+    <meta http-equiv="Cache-Control" content="no-siteapp" />
+    <#include "/base/add_base.ftl">
+    <title>添加店铺信息</title>
+</head>
+<body>
+<div class="pd-20">
+    <form action="/admin/salesOrder/updateStoreInfo" method="post" class="form form-horizontal" id="form-admin-add">
+        <input type="hidden" name="storeId" value="${storeInfo.storeId!''}">
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>所属公司:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+
+                <select class="select" style="height: 35px" name="companyId" id="companyId">
+                    <#list list as d>
+                        <option value="${d.companyId}"  <#if storeInfo.companyId??><#if storeInfo.companyId==d.companyId>selected</#if></#if> >${d.companyName}</option>
+                    </#list>
+                </select>
+
+            </div>
+            <div class="col-4"> </div>
+        </div>
+
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>店铺名称:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeName" name="storeName" datatype="s1-30" nullmsg="不能为空" value="${storeInfo.storeName!''}">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>Efast:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeEfast" name="storeEfast" datatype="s1-30" nullmsg="不能为空" value="${storeInfo.storeEfast!''}">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>发货人名称:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeShipName" name="storeShipName" datatype="s1-30" nullmsg="不能为空" value="${storeInfo.storeShipName!''}" >
+            </div>
+            <div class="col-4"> </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>发货人电话号码:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeShipTel" name="storeShipTel" datatype="s1-30" nullmsg="不能为空" value="${storeInfo.storeShipTel!''}">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>发货人省份:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeShipProvince" name="storeShipProvince" datatype="s1-30" nullmsg="不能为空" value="${storeInfo.storeShipProvince!''}">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>发货人城市:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeShipCity" name="storeShipCity" datatype="s1-30" nullmsg="不能为空" value="${storeInfo.storeShipCity!''}">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>发货人地址:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeShipAddress" name="storeShipAddress" datatype="s1-30" nullmsg="不能为空" value="${storeInfo.storeShipAddress!''}">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3" style="padding-left: 0;margin-left: 0px;width: 17%;"><span class="c-red">*</span>备注信息:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <input type="text" class="input-text" id="storeRemark" name="storeRemark"  value="${storeInfo.storeRemark!''}">
+            </div>
+            <div class="col-4"> </div>
+        </div>
+
+        <div class="row cl">
+            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
+                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
+            </div>
+        </div>
+    </form>
+</div>
+</body>
+<script type="text/javascript">
+    /* 开启校验 */
+    $(function(){
+        $('.skin-minimal input').iCheck({
+            checkboxClass: 'icheckbox-blue',
+            radioClass: 'iradio-blue',
+            increaseArea: '20%'
+        });
+
+        $("#form-admin-add").Validform({
+            tiptype:function(msg,o,cssctl){
+                if (o.type == 3) {
+                    layer.msg(msg,{icon:2,time:1500});
+                }
+            },
+            ignoreHidden: false,
+            callback:function(form){
+                var send = true;
+                if (typeof user_callback != "undefined") {
+                    send = user_callback();
+                }
+                if (typeof send == "undefined") {
+                    add();
+                }
+                if (send) {
+                    add();
+                }
+                return false;
+            }
+        });
+    });
+
+    /* 当前方法 */
+    function add() {
+        //此处请求后台程序,下方是成功后的前台处理……
+        ajax("POST", $("#form-admin-add").attr("action"), formatJSON(), function(res) {
+            if (res.resultCode == 200 && res.returnCode == 200) {
+                layer.msg('操作成功!',{icon: 6,time:1000}, function (){
+                    var index = parent.layer.getFrameIndex(window.name);
+                    if (typeof index != "undefined") {
+                        parent.layer.close(index);
+                    } else {
+                        var href = window.redirect_url;
+                        if (typeof href != "undefined") {
+                            location.href = root_path + href;
+                        }
+                    }
+                });
+            } else {
+                var error = null;
+                try {
+                    error = res.returnMsg.error;
+                } catch (error) {
+
+                }
+                if (error != null && typeof error != "undefined") {
+                    layer.msg("【操作失败】" + error,{icon: 1,time:3000});
+                } else {
+                    layer.msg('请求失败,请重试!',{icon: 1,time:1000});
+                }
+            }
+        });
+    }
+
+    /*将表单format 为  JSON*/
+    function formatJSON() {
+        var o={};
+        $($("#form-admin-add").serializeArray()).each(function(){
+            if (this.value != "" && this.value != null) {
+                // 如果value为空,则不要填充啦
+                if (o[this.name] !== undefined) {
+                    if (!o[this.name].push) {
+                        o[this.name] = [o[this.name]];
+                    }
+                    o[this.name].push(this.value || '');
+                } else {
+                    o[this.name] = this.value || '';
+                }
+            }
+        });
+        return o;
+    }
+
+    /**
+     * Ajax请求封装
+     * @param type              请求方式:GET、POST
+     * @param uri               请求URI
+     * @param data              请求数据
+     * @param success_Callback  请求成功时的回调地址
+     */
+    function ajax(type, uri, data, success_Callback) {
+        type = type || "POST";
+        var index = null;
+        $.ajax({
+            type: type,
+            url: root_path + uri,
+            data: data,
+            dataType: "json",
+            traditional: true,
+            beforeSend: function () {
+                /* AJAX请求前,展示加载层 */
+                index = layer.load(0, {zIndex:1989101500, isOutAnim:true, shade: [0.8,'#fff']});
+            },
+            success: function(data){
+                /* 请求成功 判断是否触发服务器逻辑的错误 */
+                if (data.error) {
+                    /* 如果触发错误,则不会回调成功方法 */
+                    var info = (data.error == "auth_error") ? "[权限有误] 请联系管理员分配对应权限!" : "[服务器错误]" + data.error_msg;
+                    layer.msg(info,{icon: 1,time:1700});
+                    return;
+                }
+                /* 回调成功的方法 */
+                success_Callback(data);
+            },
+            complete: function (xhr) {
+                /* 请求结束后 关闭加载层 */
+                layer.close(index);
+            },
+            error: function (xhr) {
+                /* 此处需要将错误,传递会服务器,以便以后分析处理 */
+                /*new Image().src = root_path + "/html_error/" + encodeURI(xhr.statusText);
+                layer.msg('请求失败,请重试!',{icon: 1,time:1000});*/
+                try {
+                    var data = JSON.parse(xhr.responseText);
+                    var info = (data.error == "auth_error") ? "[权限有误] 请联系管理员分配对应权限!" : "[服务器错误]" + data.error_msg;
+                    layer.msg(info,{icon: 1,time:1700});
+                } catch (e) {
+                    new Image().src = root_path + "/html_error/" + encodeURI(xhr.statusText);
+                    layer.msg('请求失败,请重试!',{icon: 1,time:1000});
+                }
+            }
+        });
+    }
+</script>
+</html>