昨天,微信全面开放了他的小程序微信小商店,所有的个人,个体户或者公司都可以申请使用。详细可以看这篇文章 https://mp.weixin.qq.com/s/nt3h4_03eKk88FZltmZNMA
这就像当年的淘宝一样,全面都可以免费开店了,而且还有微信十几亿用户的加持,让全民开店不再是问题了。
商家可以在上面免费开店,但是对于一些比较特殊的需求,比如如何实现下单以后的订单自动打印呢?比如一些做餐饮,做外卖的,需要客户下单自动打印订单,要怎么实现呢?
今天我们就来给大家讲解下微信小程序的商店如何实现自动打印。我们先看微信官方的文档。这个接口文档可以获取订单列表,
https://developers.weixin.qq.com/doc/ministore/minishopopencomponent/API/order/get_order_list.html
这个接口文档可以获取订单详情
https://developers.weixin.qq.com/doc/ministore/minishopopencomponent/API/order/get_order_detail.html
能获取到店铺的订单列表,同时还可以获取到订单详情,那么实现打印就不再是问题了。
你可以实现比如通过手工点击打印,或者实现客户一下单,自动推送到网络打印机上,让打印机自动打印订单就可以了。
获取订单列表的方式:
接口调用请求说明 http请求方式:POST https://api.weixin.qq.com/product/order/get_list?access_token=xxxxxxxxx 请求参数示例 { "start_create_time": "2020-03-25 12:05:25", "end_create_time": "2020-04-25 12:05:25", "status": 23, "page": 1, "page_size": 10 } 回包示例 { "errcode": 0, "errmsg":"ok", "orders": [ { "order_id":32434234, "status": 23, "craete_time": "2020-03-25 13:05:25", "update_time": "2020-03-25 14:05:25", "order_detail": { "product_infos": [ { "product_id": 234245, "sku_id":23424, "sku_cnt": 10, "on_aftersale_sku_cnt": 10, "finish_aftersale_sku_cnt": 0, "title":"健身环", "thumb_img": "http://img10.360buyimg.com/n1/s450x450_jfs/t1/85865/39/13611/488083/5e590a40E4bdf69c0/55c9bf645ea2b727.jpg", "sku_attrs": [ { "attr_key": "选择颜色", "attr_value": "红蓝主机" } ], "slae_price": 2000 }, ... ] "pay_info": { "pay_method": "微信支付", "prepay_id": "42526234625", "transaction_id": "131456479687", "prepay_time": "2020-03-25 14:04:25" "pay_time": "2020-03-25 14:05:25" }, "price_info": { "product_price": 20000, "order_price": 10500, "freight": 500, "discounted_price": 10000 "is_discounted": 1 } "delivery_info": { "delivery_method": "快递", "delivery_time": "2020-03-25 16:05:25", "delivery_product_info": { "waybill_id": "134654612313", "delivery_id": "10" } "address_info": { "user_name":"陈先生", "postal_code": "2435245", "province_name": "广东", "city_name": "广州", "county_name": "海珠区", "detail_info": "大塘", "national_code": "234234", "tel_number": "24534252" } } }, "after_sale_info": { "aftersale_order_list": [ { "aftersale_order_id": 1234 } ], "on_aftersale_order_cnt": 1 }, "openid": "xxxxx" }, ... ], "total_num": 20 }
获取订单的详情:
接口调用请求说明
http请求方式:POST
https://api.weixin.qq.com/product/order/get?access_token=xxxxxxxxx
请求参数示例
{
"order_id":32423523451235145
}
返回的数据格式示例
{ "errcode": 0, "errmsg":"ok", "order": { "order_id":32434234, "status": 23, "craete_time": "2020-03-25 13:05:25", "update_time": "2020-03-25 14:05:25", "order_detail": { "product_infos": [ { "product_id": 234245, "sku_id":23424, "sku_cnt": 10, "on_aftersale_sku_cnt": 10, "finish_aftersale_sku_cnt": 0, "title":"健身环", "thumb_img": "http://img10.360buyimg.com/n1/s450x450_jfs/t1/85865/39/13611/488083/5e590a40E4bdf69c0/55c9bf645ea2b727.jpg", "sku_attrs": [ { "attr_key": "选择颜色", "attr_value": "红蓝主机" } ], "slae_price": 2000 }, ... ] "pay_info": { "pay_method": "微信支付", "prepay_id": "42526234625", "transaction_id": "131456479687", "prepay_time": "2020-03-25 14:04:25" "pay_time": "2020-03-25 14:05:25" }, "price_info": { "product_price": 20000, "order_price": 10500, "freight": 500, "discounted_price": 10000 "is_discounted": 1 } "delivery_info": { "delivery_method": "快递", "delivery_time": "2020-03-25 16:05:25", "delivery_product_info": { "waybill_id": "134654612313", "delivery_id": "10" } "address_info": { "user_name":"陈先生", "postal_code": "2435245", "province_name": "广东", "city_name": "广州", "county_name": "海珠区", "detail_info": "大塘", "national_code": "234234", "tel_number": "24534252" } } }, "after_sale_info": { "aftersale_order_list": [ { "aftersale_order_id": 1234 } ], "on_aftersale_order_cnt": 1 }, "openid": "xxxxx" } }
这样就成功获取到了订单的详情。然后使用代码将订单详情推送给打印机打印即可。
好了,今天就给大家分享到这里。 秋峰,phper、javascript前端开发,目前自创业,做项目系统开发,做公众号以及小程序等的开发, 今天就给大家分享到这里,希望对大家有所帮助。
欢迎交流 大家相互学习 我的 微信号 qiufeng2983