Commit 0d4e670e authored by sunc's avatar sunc

修改线下出库

parent 04109897
......@@ -35,4 +35,11 @@ public interface OrderDetailsMapper extends GenericDao<OrderDetails> {
* @return
*/
List<OrderSplitBatchDto> fetchSearchByBatchDrug(Map<String, Object> params);
/**
* 根据订单id查询订单明细批次号
* @param orderId
* @return
*/
OrderSplitBatchDto getDetailsByOrderId(Long orderId);
}
\ No newline at end of file
......@@ -282,4 +282,12 @@
ORDER BY t.drugs_id DESC, t.create_time DESC
<if test="limit>0">limit #{offset},#{limit}</if>
</select>
<select id="getDetailsByOrderId" parameterType="java.lang.Long" resultType="com.cftech.orderdetail.model.OrderSplitBatchDto">
SELECT o.id orderId,o.number orderCode,o.openid openid,t.id drugsId,
t.product_number drugsCode,t.common_name drugsName,o.accounts_id accountsId FROM t_order o
LEFT JOIN t_order_details d ON o.id = d.order_id
LEFT JOIN t_aidea_product t ON d.drugs_id = t.id
WHERE o.id = #{orderId} LIMIT 0,1
</select>
</mapper>
\ No newline at end of file
......@@ -47,4 +47,11 @@ public interface OrderDetailsService extends GenericService<OrderDetails> {
* @return
*/
List<OrderSplitBatchDto> fetchSearchByBatchDrug(Conds conds, Sort sort, int page, int pageSize);
/**
* 根据订单id查询订单明细批次号
* @param orderId
* @return
*/
OrderSplitBatchDto getDetailsByOrderId(Long orderId);
}
......@@ -70,4 +70,9 @@ public class OrderDetailsServiceImpl extends GenericServiceImpl<OrderDetails> im
params.put("sort", sort);
return orderDetailsMapper.fetchSearchByBatchDrug(params);
}
@Override
public OrderSplitBatchDto getDetailsByOrderId(Long orderId) {
return orderDetailsMapper.getDetailsByOrderId(orderId);
}
}
\ No newline at end of file
......@@ -382,7 +382,6 @@
goodsList = JSON.parse(res.data);
if (isView == "true") {//查看
let details = `$!{list}`;
console.log(details);
if (details != null && details != '' && details != '[]') {
let arr = JSON.parse(details);
for (let i = 0; i < arr.length; i++) {
......
......@@ -383,9 +383,11 @@
html += '<a data-action="view" class="btn green" href="#springUrl("/a/order/findorderDetail?id=' + a + '&isDetail=y")">查看清单明细</a>';
if (c.status == '2') {//待发货才可以出库操作
html += '<a data-action="remove" class="btn red" href="#springUrl("/a/order/sendOut?pageType=Edit&id=' + a + '")">订单出库</a>';
html += '<a data-action="remove" class="btn red" href="#springUrl("/a/order/offlineOrder?pageType=Edit&id=' + a + '")">线下出库</a>';
}
if (c.status == '3' || c.status == '4') {//
html += '<a data-action="view" class="btn green" href="#springUrl("/a/order/sendOut?pageType=View&id=' + a + '")">订单出库详情</a>';
// html += '<a data-action="remove" class="btn red" href="#springUrl("/a/order/offlineOrder?pageType=View&id=' + a + '")">线下出库详情</a>';
}
html += '#end';
return html;
......
......@@ -104,4 +104,18 @@ public interface OrderMapper extends GenericDao<Order> {
* @return
*/
BigDecimal findUserDrugsPatientsSum(String openid);
/**
* 保存线下出库单
* @param offlineOrder
* @return
*/
Integer saveOfflineOrder(OfflineOrder offlineOrder);
/**
* 生成物流单
* @param waybillDto
* @return
*/
Integer saveWaybill(WaybillDto waybillDto);
}
\ No newline at end of file
......@@ -193,6 +193,40 @@
update t_order_details set del_flag=1 where id=#{id}
</update>
<insert id="saveOfflineOrder" parameterType="com.cftech.order.model.OfflineOrder" useGeneratedKeys="true"
keyProperty="id">
insert into t_offline_order
(
`waybill_no`,
`consult_id`,
`order_id`,
`contact`,
`mobile`,
`status`,
`temperature_range`,
`storage_manage`,
`send_express_date`,
`accept_express_date`,
`batch_num`,
`drugs_num`
)
values
(
#{waybillNo, jdbcType=VARCHAR},
#{consultId, jdbcType=VARCHAR},
#{orderId, jdbcType=VARCHAR},
#{contact, jdbcType=VARCHAR},
#{mobile, jdbcType=VARCHAR},
#{status, jdbcType=VARCHAR},
#{temperatureRange, jdbcType=VARCHAR},
#{storageManage, jdbcType=VARCHAR},
#{sendExpressDate, jdbcType=TIMESTAMP},
#{acceptExpressDate, jdbcType=TIMESTAMP},
#{batchNum, jdbcType=VARCHAR},
#{drugsNum, jdbcType=BIGINT}
)
</insert>
<select id="fetchId" parameterType="java.lang.Long" resultType="com.cftech.order.model.OrderFromVO">
SELECT
......@@ -209,6 +243,7 @@
o.create_time AS createTime,
o.confirm,
o.courier_number AS courierNumber,
cs.consult_id AS consultCode,
o.address_des AS addressDes,
o.openid,
o.remarks,
......@@ -221,6 +256,7 @@
qyu.name storageManageName
from
t_order o
LEFT JOIN t_aidea_consult_sheet cs ON o.consult_id = cs.id
LEFT JOIN t_shipping_address s ON o.address_id = s.id
LEFT JOIN t_aidea_waybill aw ON o.id = aw.order_id
LEFT JOIN user u ON u.id = aw.storage_manage
......@@ -744,4 +780,85 @@
t_order t
WHERE t.del_flag = 0 AND t.openid = #{openid}
</select>
<sql id="insertSqlColumns">
consult_id,
order_id,
number,
member_id,
open_id,
storage_manage,
waybill_no,
language,
monthly_card,
express_type_id,
temperature_range,
contact,
mobile,
province,
city,
county,
address,
address_id,
send_express_date,
accept_express_date,
waybill_remark,
accounts_id,
del_flag,
status,
create_time,
update_time,
description,
create_by,
update_by,
route_des,
filter_result,
dest_code,
origin_code
</sql>
<insert id="saveWaybill" parameterType="com.cftech.order.model.WaybillDto" useGeneratedKeys="true">
insert into t_aidea_waybill
(
<include refid="insertSqlColumns"/>
)
values
(
#{consultId, jdbcType=BIGINT},
#{orderId, jdbcType=BIGINT},
#{number, jdbcType=VARCHAR},
#{memberId, jdbcType=VARCHAR},
#{openId, jdbcType=VARCHAR},
#{storageManage, jdbcType=VARCHAR},
#{waybillNo, jdbcType=VARCHAR},
#{language, jdbcType=VARCHAR},
#{monthlyCard, jdbcType=VARCHAR},
#{expressTypeId, jdbcType=VARCHAR},
#{temperatureRange, jdbcType=VARCHAR},
#{contact, jdbcType=VARCHAR},
#{mobile, jdbcType=VARCHAR},
#{province, jdbcType=VARCHAR},
#{city, jdbcType=VARCHAR},
#{county, jdbcType=VARCHAR},
#{address, jdbcType=VARCHAR},
#{addressId, jdbcType=VARCHAR},
#{sendExpressDate, jdbcType=TIMESTAMP},
#{acceptExpressDate, jdbcType=TIMESTAMP},
#{waybillRemark, jdbcType=VARCHAR},
#{accountsId, jdbcType=BIGINT},
#{delFlag, jdbcType=TINYINT},
#{status, jdbcType=VARCHAR},
now(),
now(),
#{description, jdbcType=VARCHAR},
#{createBy, jdbcType=BIGINT},
#{updateBy, jdbcType=BIGINT},
#{routeDes, jdbcType=VARCHAR},
#{filterResult, jdbcType=VARCHAR},
#{destCode, jdbcType=VARCHAR},
#{originCode, jdbcType=VARCHAR}
)
</insert>
</mapper>
\ No newline at end of file
......@@ -44,6 +44,6 @@ public class OrderFromVO {
private String acceptExpressDateStr;
private String payTime;
private String storageManageName;
private String consultCode; /* 咨询单编码 */
}
......@@ -136,4 +136,11 @@ public interface OrderService extends GenericService<Order> {
*/
String findOrderPayParams(String openId, String appId, String prepayId);
/**
* 线下出库保存
* @param datas
* @return
*/
JSONObject saveOfflineOrder(String datas, HttpServletRequest request);
}
package com.cftech.order.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
......@@ -33,17 +36,20 @@ import com.cftech.core.sql.Conds;
import com.cftech.order.utils.InvoiceUtil;
import com.cftech.orderdetail.dao.OrderDetailsMapper;
import com.cftech.orderdetail.model.OrderDetails;
import com.cftech.orderdetail.model.OrderSplitBatchDto;
import com.cftech.orderdetail.service.OrderDetailsService;
import com.cftech.prescription.model.Prescription;
import com.cftech.prescription.service.PrescriptionService;
import com.cftech.product.model.Product;
import com.cftech.product.service.ProductService;
import com.cftech.sys.security.UserUtils;
import com.cftech.wechat.pay.WechatPayUtils;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TreeTableColumn;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.NoTransactionException;
import org.springframework.transaction.annotation.Transactional;
......@@ -765,6 +771,46 @@ public class OrderServiceImpl extends GenericServiceImpl<Order> implements Order
return retObj.toString();
}
@Override
public JSONObject saveOfflineOrder(String datas, HttpServletRequest request) {
JSONObject jsonObject = new JSONObject();
OfflineOrder offlineOrder = serializeToBean(datas);
Integer integer = orderMapper.saveOfflineOrder(offlineOrder);
//更新订单状态
this.updateStatus(offlineOrder.getOrderId(), offlineOrder.getStatus(), "线下发货");
//生成物流单
WaybillDto waybillDto = new WaybillDto();
Long accountsId = UserUtils.getmpaccounts(request);
BeanUtil.copyProperties(offlineOrder, waybillDto);
waybillDto.setDelFlag(false);
waybillDto.setAccountsId(accountsId);
waybillDto.setCreateBy(UserUtils.getUser().getId());
waybillDto.setUpdateBy(UserUtils.getUser().getId());
waybillDto.setOpenId(offlineOrder.getOpenId());
waybillDto.setNumber(codingruleUtils.getNumber(accountsId, "com.cftech.waybill.model.Waybill"));
waybillDto.setCreateTime(offlineOrder.getSendExpressDate());
waybillDto.setUpdateTime(DateUtil.date());
orderMapper.saveWaybill(waybillDto);
//生成订单明细表(批次号)
OrderSplitBatchDto orderSplitBatch = orderDetailsService.getDetailsByOrderId(offlineOrder.getOrderId());
orderSplitBatch.setDrugsNum(offlineOrder.getDrugsNum());
orderSplitBatch.setDrugsBatchNo(offlineOrder.getBatchNum());
orderSplitBatch.setCreateTime(offlineOrder.getSendExpressDate());
orderSplitBatch.setUpdateTime(DateUtil.date());
orderDetailsService.saveDrugBatchNo(orderSplitBatch);
jsonObject.put("errorNo", "0");
if (integer < 0) {
jsonObject.put("errorNo", "1");
}
return jsonObject;
}
public OfflineOrder serializeToBean(String datas){
datas = StringEscapeUtils.unescapeHtml4(datas).replace("+", " ");
OfflineOrder offlineOrder = JSONUtil.toBean(JSONUtil.parseObj(datas), OfflineOrder.class);
return offlineOrder;
}
@Override
public boolean sendQyWechatMassage(Long orderId, String msgType) {
Long accounts = Long.parseLong(SystemConfig.p.getProperty("QY_SEND_APPID"));
......
......@@ -43,6 +43,7 @@ import org.springframework.transaction.UnexpectedRollbackException;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
......@@ -204,6 +205,51 @@ public class OrderController {
return "order/orderSendOut";
}
//线下出库页面
@RequiresPermissions(value = ORDER_VIEW)
@RequestMapping("/offlineOrder")
public String sendOutConfirm(HttpServletRequest request, String id, Model model, String pageType) {
if (StringUtils.isNoneBlank(id)) {
OrderFromVO orderFromVO = orderService.fetchId(id);
//JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(orderFromVO));
JSONObject jsonObject = new JSONObject();
User user = UserUtils.getUser();
jsonObject.put("consultId", orderFromVO.getConsultId());
jsonObject.put("consultSheetCode", orderFromVO.getConsultCode());
jsonObject.put("orderId", id);
jsonObject.put("orderCode", orderFromVO.getNumber());
jsonObject.put("storageManage", user.getId());
jsonObject.put("storageManageName", user.getUsername());
jsonObject.put("openId", orderFromVO.getOpenid());
model.addAttribute("data", jsonObject);
}
model.addAttribute("pageType", StringUtils.equals(pageType, "View") ? true : false);
return "order/offlineOrder";
}
//线下出库保存
@RequiresPermissions(value = ORDER_EDIT)
@PostMapping(value = "/saveOfflineOrder")
@ResponseBody
public JSONObject saveOfflineOrder(String datas, HttpServletRequest request) {
//解析json字符串
JSONObject jsonObject = null;
try {
jsonObject = orderService.saveOfflineOrder(datas, request);
} catch (UnexpectedRollbackException e) {
if (jsonObject == null)
jsonObject = new JSONObject();
jsonObject.put("errorNo", 1);
e.printStackTrace();
} catch (Exception e) {
if (jsonObject == null)
jsonObject = new JSONObject();
jsonObject.put("errorNo", 1);
e.printStackTrace();
}
return jsonObject;
}
@RequestMapping("/fromProduct")
@ResponseBody
public JSONObject fromProduct() {
......
......@@ -29,6 +29,7 @@ import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment